jpan
05-03-2004, 08:08 AM
Hi,
I have an XML that's loaded through HTTP into a dataset, and the XML looks like
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
</XMLMessage>
Now, I want to add a node into here, and the result XML should look like:
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
<!-- NEW DATA HERE -->
<AdditionalList />
</XMLMessage>
The reason for this is because, later on in the processing, I want to add nodes into "AdditionalList", such that the XML will look like this:
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
<!-- NEW DATA HERE -->
<AdditionalList />
<Record>Additional 1</Record>
<Record>Additional 2</Record>
<Record>Additional 3</Record>
</AdditionalList>
</XMLMessage>
The node "AdditionalList" is not in the source http XML because of some other problems and cannot be added easily, which is why I'm doing it in the client.
The code I use to add "AdditionalList" node is:
dataPointer.setXPath( "RemoteMessage:/XMLMessage");
dataPointer.addNode("AdditionalList", "");
And then to add the children nodes to it, I use:
dataPointer.setXPath( "RemoteMessage:/XMLMessage/AdditionalList");
dataPointer.addNode("Record", dataString);
This doesn't work properly, as I noticed an additional child-node in "AdditionalList". My assumption is that the original text node added to AdditionalList is getting counted.
How can I deal with this? I really only want to put in a place-holder node in the XML that will allow me to add/remove child-nodes into the place-holder... OR, is there a better way to accomplish what I need to do??
Thank you!
I have an XML that's loaded through HTTP into a dataset, and the XML looks like
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
</XMLMessage>
Now, I want to add a node into here, and the result XML should look like:
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
<!-- NEW DATA HERE -->
<AdditionalList />
</XMLMessage>
The reason for this is because, later on in the processing, I want to add nodes into "AdditionalList", such that the XML will look like this:
<XMLMessage>
<Units>
<Record>Data 1</Record>
<Record>Data 2</Record>
<Record>Data 3</Record>
</Units>
<!-- NEW DATA HERE -->
<AdditionalList />
<Record>Additional 1</Record>
<Record>Additional 2</Record>
<Record>Additional 3</Record>
</AdditionalList>
</XMLMessage>
The node "AdditionalList" is not in the source http XML because of some other problems and cannot be added easily, which is why I'm doing it in the client.
The code I use to add "AdditionalList" node is:
dataPointer.setXPath( "RemoteMessage:/XMLMessage");
dataPointer.addNode("AdditionalList", "");
And then to add the children nodes to it, I use:
dataPointer.setXPath( "RemoteMessage:/XMLMessage/AdditionalList");
dataPointer.addNode("Record", dataString);
This doesn't work properly, as I noticed an additional child-node in "AdditionalList". My assumption is that the original text node added to AdditionalList is getting counted.
How can I deal with this? I really only want to put in a place-holder node in the XML that will allow me to add/remove child-nodes into the place-holder... OR, is there a better way to accomplish what I need to do??
Thank you!