XML Version
-
Hi, Am totally new to the XML part.... i am creating an XML using XMLDocument. have created parent nodes, attributes, child nodes etc.. I wanted to get <?xml version="1.0" standalone="yes"?> at the top of the XML. How will I be able to mention the XML version on the top of it. Any help appreciated. Thanks Rijz
-
Hi, Am totally new to the XML part.... i am creating an XML using XMLDocument. have created parent nodes, attributes, child nodes etc.. I wanted to get <?xml version="1.0" standalone="yes"?> at the top of the XML. How will I be able to mention the XML version on the top of it. Any help appreciated. Thanks Rijz
-
When you save your XmlDocument either to a file or stream it will automatically create that for you.
-
Thanks for the reply. I am saving the creatred XML using the save method into a physical Location as xmlDoc.Save(@"d://xmltest/InputxmlNew.xml")... But the version is not getting displayed. Am I missing something somewhere? Thanks Rijz
Opps - sorry will edit this when I've sorted it! Solution (NB: declaration node!):
System.Xml.XmlDocument MyXmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNode DeclarationNode = MyXmlDoc.CreateNode(System.Xml.XmlNodeType.XmlDeclaration, "", "");
MyXmlDoc.AppendChild(DeclarationNode);
System.Xml.XmlElement RootElement = MyXmlDoc.CreateElement("", "root", "");
MyXmlDoc.AppendChild(RootElement);
MyXmlDoc.Save(@"C:\\test.xml");modified on Friday, February 8, 2008 6:55 AM
-
Opps - sorry will edit this when I've sorted it! Solution (NB: declaration node!):
System.Xml.XmlDocument MyXmlDoc = new System.Xml.XmlDocument();
System.Xml.XmlNode DeclarationNode = MyXmlDoc.CreateNode(System.Xml.XmlNodeType.XmlDeclaration, "", "");
MyXmlDoc.AppendChild(DeclarationNode);
System.Xml.XmlElement RootElement = MyXmlDoc.CreateElement("", "root", "");
MyXmlDoc.AppendChild(RootElement);
MyXmlDoc.Save(@"C:\\test.xml");modified on Friday, February 8, 2008 6:55 AM