Change Value of Existing Element

  • Thread starter Thread starter Lee
  • Start date Start date
L

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.
 
Hi,

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

Ken
------------------

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.
 
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top