Change Value of Existing Element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lee

    #1

    Change Value of Existing Element


    I have an xml Structure:

    <?xml version="1.0" encoding="utf-16"?>
    <Request>
    <Operations>
    <Command>
    <OpType>login </OpType>
    <Params>
    <UserName>leebo </UserName>
    <Password>leebo </Password>
    </Params>
    </Command>
    </Operations>
    </Request>

    I'm trying to find out how to change the value of an element, say
    <userName>joh n</UserName>

    I'm using an XmlDocument, but I've been searching MSDN and google
    groups for a couple of hours and I can't seem to find an answer.

    Must I create and use an XMLWriter to perform this one small function?

    Basically, I just need to change one element's value.

    Sorry for such as basic question.

    --
    Warm Regards,

    Lee
  • Ken Tucker [MVP]

    #2
    Re: Change Value of Existing Element

    Hi,

    Yes. You must read in the document and write it back with the
    changes.

    Ken
    ------------------
    "Lee" <luv2program200 0@yahoo.com> wrote in message
    news:%23GW5GGff FHA.3936@TK2MSF TNGP10.phx.gbl. ..

    I have an xml Structure:

    <?xml version="1.0" encoding="utf-16"?>
    <Request>
    <Operations>
    <Command>
    <OpType>login </OpType>
    <Params>
    <UserName>leebo </UserName>
    <Password>leebo </Password>
    </Params>
    </Command>
    </Operations>
    </Request>

    I'm trying to find out how to change the value of an element, say
    <userName>joh n</UserName>

    I'm using an XmlDocument, but I've been searching MSDN and google
    groups for a couple of hours and I can't seem to find an answer.

    Must I create and use an XMLWriter to perform this one small function?

    Basically, I just need to change one element's value.

    Sorry for such as basic question.

    --
    Warm Regards,

    Lee


    Comment

    • Lee

      #3
      Re: Change Value of Existing Element

      Ken Tucker [MVP] enlightened me by writing:
      [color=blue]
      > Hi,
      >
      > Yes. You must read in the document and write it back
      > with the changes.
      >
      > Ken[/color]

      Thanks Ken. Can you provide a link to sample? I'd really appreciate
      it.

      Thanks again,

      --
      Warm Regards,

      Lee

      Comment

      Working...