CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2011
    Posts
    27

    Question Variables in xml

    Hello,

    We have these xml formatted .config files that come with all our ASP.NET programs. Well they have keys that need to be populated and I am unable to understand how to create a variable in xml and use it. The articles on variables in xml all seem to be talking about some other type of variable than I am familiar with. I am used to working in C or other programming languages.

    I want to do something like

    MyVariable = "SomeString"

    <add key="Key1" value=MyVariable>


    Anyone know how?

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Variables in xml

    Xml is a markup language. You can have your tags and your attributes and your values, but you cannot have "variables" or flow control statement. You could have both them in the parser, in an xls file, in xslt, ...

    That is : xml per se carries data, organized via tags, even with attributes. You could code inside several values, but is up to the parser (or to the writer to assign) to switch between these values and node names and attributes to show (or hide) them as you want
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Apr 2011
    Posts
    27

    Re: Variables in xml

    Sorry I am lost in this. I am a network admin and I have millions of these config files, they all have these keys that need to be set to the same exact value. The value is a long complex string value and by entering the string only once it would reduce the risk for mistakes.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Variables in xml

    I am used to working in C or other programming languages.
    XML files are text files. If you can find a program that will open a batch of files and edit them, it should work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Variables in xml

    If you truly have a lot of these files then it may be worth while to create a program that will do a batch edit. Should not be that hard to do.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured