Hello!
I want to make a xmlstructure like this:
This is my code so far:Code:<?xml version="1.0" ?> <ROOT> This is the text of the root element <SupplierID> Supplier id <SupplierName>Supplier name</SupplierName> </SupplierID> </ROOT>
now my problem I don't know how to add a node into my first node SupplierID?Code:xmldoc = new XmlDocument(); //let's add the XML declaration section xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); xmldoc.AppendChild(xmlnode); //let's add the root element xmlelem = xmldoc.CreateElement("", "ROOT", ""); xmltext = xmldoc.CreateTextNode("This is the text of the root element"); xmlelem.AppendChild(xmltext); xmldoc.AppendChild(xmlelem); //let's add another element (child of the root) xmlelem2 = xmldoc.CreateElement("", "SupplierID", ""); xmltext = xmldoc.CreateTextNode("Supplier id"); xmlelem2.AppendChild(xmltext); xmldoc.ChildNodes.Item(1).AppendChild(xmlelem2);




Reply With Quote