Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. External Variables???

External Variables???

Scheduled Pinned Locked Moved C#
questioncsharphtmlxmltutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bscott3125
    wrote on last edited by
    #1

    Ok, I'll try to make this as short as possible. I have wrote a C# app that creates static HTML pages. One of the pieces for each page is obviously the keyword meta tags. To thicken the plot, this same program generates the same pages for different sites. But different keywords for each site. What I'm trying to accomplish is to have an external XML file that basically "defines" what the keywords are for each site. My question is this, what if I want to change say the Persons name for each of my pages, but using the same keywords. Example: Visit Bob Smith's Home Page My Application is going to have the name Bob Smith defined, so basically when I import my XML it needs to have a place for a variable. So the XML file should read Example "Visit" + theName + " Home Page". So when it comes into my app + theName + get's defined as Bob Smith's. Obviously it doesn't work this way and I need it to. Any ideas. Hope I haven't confused the hell out of everyone :) -Brent

    M 1 Reply Last reply
    0
    • B bscott3125

      Ok, I'll try to make this as short as possible. I have wrote a C# app that creates static HTML pages. One of the pieces for each page is obviously the keyword meta tags. To thicken the plot, this same program generates the same pages for different sites. But different keywords for each site. What I'm trying to accomplish is to have an external XML file that basically "defines" what the keywords are for each site. My question is this, what if I want to change say the Persons name for each of my pages, but using the same keywords. Example: Visit Bob Smith's Home Page My Application is going to have the name Bob Smith defined, so basically when I import my XML it needs to have a place for a variable. So the XML file should read Example "Visit" + theName + " Home Page". So when it comes into my app + theName + get's defined as Bob Smith's. Obviously it doesn't work this way and I need it to. Any ideas. Hope I haven't confused the hell out of everyone :) -Brent

      M Offline
      M Offline
      MultiThread
      wrote on last edited by
      #2

      Hi Brent, It sounds almost like you want to add meta tags to your meta files. :) Actually, it's not uncommon to have a file template that is pre-processed in order to feed it to the appropriate consumer. A classic example is the pre-processor .h files used by C/C++ compilers. However, in your case, you want to take existing XML files and use them directly with text replacement. Probably not very easy to do with the XML parser directly, but perhaps you can consider this: Create your own "XML template" with a different file extension; allow a certain delimiter to define 'tags' in the XML file which don't clash with the XML syntax. Create a component which can take a collection of name-value pairs, and the name of your file to read the file, parse out the 'tags', and replace the name of the tag with the value in the collection (with the tag name as the key). The resulting text replacement is then the new "dynamic XML" that you can then feed to your application. There are probably other ways of doing such with XSL, but that's one realm I've not yet trodden. Regards, Joe

      B 1 Reply Last reply
      0
      • M MultiThread

        Hi Brent, It sounds almost like you want to add meta tags to your meta files. :) Actually, it's not uncommon to have a file template that is pre-processed in order to feed it to the appropriate consumer. A classic example is the pre-processor .h files used by C/C++ compilers. However, in your case, you want to take existing XML files and use them directly with text replacement. Probably not very easy to do with the XML parser directly, but perhaps you can consider this: Create your own "XML template" with a different file extension; allow a certain delimiter to define 'tags' in the XML file which don't clash with the XML syntax. Create a component which can take a collection of name-value pairs, and the name of your file to read the file, parse out the 'tags', and replace the name of the tag with the value in the collection (with the tag name as the key). The resulting text replacement is then the new "dynamic XML" that you can then feed to your application. There are probably other ways of doing such with XSL, but that's one realm I've not yet trodden. Regards, Joe

        B Offline
        B Offline
        bscott3125
        wrote on last edited by
        #3

        Hi Joe, Yea, that's exactly what I ended up doing. I defined variables in my XML file with @FirstName@ @LastName@ etc. and then just look for those values once I import the XML....works pretty damn nicely. Like you said, probably a better way, but I'm only dealing with about 6 variables at any one given time so it works :) Thanks for the response though!! -Brent

        M 1 Reply Last reply
        0
        • B bscott3125

          Hi Joe, Yea, that's exactly what I ended up doing. I defined variables in my XML file with @FirstName@ @LastName@ etc. and then just look for those values once I import the XML....works pretty damn nicely. Like you said, probably a better way, but I'm only dealing with about 6 variables at any one given time so it works :) Thanks for the response though!! -Brent

          M Offline
          M Offline
          MultiThread
          wrote on last edited by
          #4

          Hi there, No problem, actually, I've used that approach in the past on other project. It does work nicely and the best thing about it is that it's configurable after you've written the code that uses it. (You just have to make sure you don't break what you feed the code!) It's a good way of branding Web sites, nice to see someone out there thinking that way. :) Regards, Joe

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups