| | |
XML help with tags
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 6
Reputation:
Solved Threads: 0
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
I want it to be (notice only one Test tag)
Here is the code I use to generate it:
Thanks
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, XSLT and XPATH Syntax (Toggle Plain Text)
<?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, XSLT and XPATH Syntax (Toggle Plain Text)
<?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:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
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
•
•
Join Date: Apr 2008
Posts: 45
Reputation:
Solved Threads: 10
Rather than adding the Temp node from the dataset as a child of the Temp node from doc, you could loop through the children of myNode and add them as children of TempNode.
There's most likely other ways to do this, but it looks like it should solve your problem.
C# Syntax (Toggle Plain Text)
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); for(XmlNode child in myNode.ChildNodes) TempNode.AppendChild(child);//add the node
There's most likely other ways to do this, but it looks like it should solve your problem.
![]() |
Similar Threads
- Not able to print XML tags in the screen ( a jsp page) (JSP)
- Xml Case Sensitive (VB.NET)
- converting exe into xml (XML, XSLT and XPATH)
- What exactly is xml? (RSS, Web Services and SOAP)
- inserting label in xml tags (ASP.NET)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: I'm way out of my depth and need desperate help.
- Next Thread: Blog Aggregator: XML and XSLT
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt





