Need Serious Help adding a Node to XML doc
XmlDocument doc = new XmlDocument();
FileStream myFile = new FileStream(@"C:\ShippingOrder.xml", FileMode.Open);
doc.Load(myFile);
XmlNode root = doc.FirstChild;
//create new node
XmlElement elem = doc.CreateElement("Lio");
elem.InnerText = "ThisWillbetheSchemaRef";
//add node to the document
root.InsertBefore(elem, root.FirstChild);
myFile.Close();
Ie, I have a document Shipping:
<?xml version="1.0" encoding="ISO-8859-1"?>
<shipTo>
<name>Tom Jones</name>
<address>555 windchester drive</address>
<city>San Francisco</city>
<state>CA</state>
<country>United States</country>
</shipTo>
<items>
<item>
<title>Empires</title>
<quantity>1</quantity>
<price>50.00</price>
</item>
<item>
<title>Desert Wines</title>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Cheese O' Rama</title>
<quantity>1</quantity>
<price>9.95</price>
</item>
</items>
and I want it to be:
<?xml version="1.0" encoding="ISO-8859-1"?>
<shipOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost/XMLDemo/Shipping Order.xsd">
<shipTo>
<name>Tom Jones</name>
<address>555 windchester drive</address>
<city>San Francisco</city>
<state>CA</state>
<country>United States</country>
</shipTo>
<items>
<item>
<title>Empires</title>
<quantity>1</quantity>
<price>50.00</price>
</item>
<item>
<title>Desert Wines</title>
<quantity>1</quantity>
<price>10.90</price>
</item>
<item>
<title>Cheese O' Rama</title>
<quantity>1</quantity>
<price>9.95</price>
</item>
</items>
</shipOrder>
HELP!!!!

