Xml appending child nodes

  • Thread starter Thread starter hharry
  • Start date Start date
H

hharry

Hi All,

If I have the following xml:

<Response>
<AddressDetails>
<Address>
</Address>
</AddressDetails>
</Response>

and I need to insert multiple address records like this:

<Response>
<AddressDetails>
<Address>
<City></City>
<State></State>
</Address>
<Address>
<City></City>
<State></State>
</Address>
</AddressDetails>
</Response>

I have used the xmlnode.appendchild method to do this, but I can only
add one address, the original address is replaced so i end up with only
1 address like this:

<Response>
<AddressDetails>
<Address>
<City></City>
<State></State>
</Address>
</AddressDetails>
</Response>

Thanks in advance
 
Hi,
You'll need to also append another Address node to AddressDetails.

Marcie
 
I'm not sure what you're project is doing, but one alternative is to
create a class that models your entire XML structure and add the
Serializable attribute to it. Then you can just serialize and
deserialize directly to XML without having to deal with the xml
yourself.
 
Chris said:
I'm not sure what you're project is doing, but one alternative is to
create a class that models your entire XML structure and add the
Serializable attribute to it. Then you can just serialize and
deserialize directly to XML without having to deal with the xml
yourself.

Thanks for the pointers. I needed to declare a new set of xml nodes for
each child group!
 

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