Home All Groups Group Topic Archive Search About

Change Value of Existing Element

Author
1 Jul 2005 4:01 AM
Lee
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>john</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

Author
1 Jul 2005 7:47 AM
Ken Tucker [MVP]
Hi,

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

Ken
------------------
"Lee" <luv2program2***@yahoo.com> wrote in message
news:%23GW5GGffFHA.3936@TK2MSFTNGP10.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>john</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
Author
1 Jul 2005 5:41 PM
Lee
Ken Tucker [MVP] enlightened me by writing:

> Hi,
>
>             Yes.  You must read in the document and write it back
> with the changes.
>
> Ken

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

Thanks again,

--
Warm Regards,

Lee