Hello,
I am having a problem adding a node properly. It does add but it duplicates the Test node I know why it is doing it (I create the Test node in the root as well as in the dataset) but I don’t know how to prevent it. Any suggestions would be welcome as I have never used XML before. Thanks
<?xml version="1.0" ?>
<MyTest XMLVersion="1.3" Stamp="7/22/2009 11:55:59 PM">
<Test>
<Test>
<MyTestID>bfc7941d-70a8-48c0-a535-561a73393457</MyTestID>
<MyTestID2>ccf2757f-63s5-57h9-d437-185s63285942</MyTestID2>
<SomeText>Some Text Here</SomeText>
</Test>
</Test> </OtherNode>
I want it to be (notice only one Test tag)
<?xml version="1.0" ?>
<MyTest XMLVersion="1.3" Stamp="7/22/2009 11:55:59 PM">
<Test>
<MyTestID>bfc7941d-70a8-48c0-a535-561a73393457</MyTestID>
<MyTestID2>ccf2757f-63s5-57h9-d437-185s63285942</MyTestID2>
<SomeText>Some Text Here</SomeText>
< /Test> </OtherNode>
Here is the code I use to generate it:
string xml = "<?xml version=\"1.0\"?><MyTest XMLVersion=\"1.3\" Stamp=\"" + DateTime.Now.ToString() + "\"><Test></Test><OtherNode></OtherNode></MyTest>";
doc.LoadXml(xml);//start the xml
GetTestData(); //gets dataset loads it into an XMLDocument called doc
TempNode = doc.SelectSingleNode("//MyTest");//get the
myNode = m_myTest.SelectSingleNode("//Test");//get the node
myNode = m_MenuOnline.ImportNode(m_MyNode, true);
TempNode.AppendChild(myNode);//add the node
Thanks