Results 1 to 7 of 7

Thread: change xml's value

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    change xml's value

    Hi, I Have an xml in a format like this:

    <Client>Test</Client>
    <Client>Test2 </Client>

    Now, when the user submits say he/she selects Test2, behind the code, I want to change that "Test 2" value to "User select Test 2", can I accomplish that?

  2. #2
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: change xml's value

    Load a xmlDocument object with your xml file. Then selectSingleNode - the node you want to change, set the nodes innerText property to "your text" then save the xmlDocument.

    If you get stuck let us know.

  3. #3
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: change xml's value

    Fyi, XmlDocument is pretty slow. XmlReader would be faster. Serialization may even be an option.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: change xml's value

    You can also use XPathNavigator.SetValue.

  5. #5
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: change xml's value

    Quote Originally Posted by kasracer
    Fyi, XmlDocument is pretty slow. XmlReader would be faster. Serialization may even be an option.
    How are you going to modify then save a xml file with a xmlReader? Is that not what needs to be done...

    I guess it's open to interpretation... perhaps vbbit can let us know.

  6. #6
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: change xml's value

    Quote Originally Posted by brin351
    How are you going to modify then save a xml file with a xmlReader? Is that not what needs to be done...

    I guess it's open to interpretation... perhaps vbbit can let us know.
    XmlWriter
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  7. #7
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: change xml's value

    Quote Originally Posted by kasracer
    XmlWriter
    OK but you will have to re-create the entire xml documented with the change, instead of just makeing the change.. or am I missing something

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