Creating an xml document with the xsi:schemalocation attribute.
Everytime i create the file it takes the xsi prefix off! Anyideas why it would do this?
See Code below![]()
Code:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim xmldoc As New System.Xml.XmlDocument Dim xmlproc As System.Xml.XmlDeclaration Dim xmlroot As System.Xml.XmlElement Dim xmlchild As System.Xml.XmlElement Dim xmlAttri As System.Xml.XmlAttribute Dim xmlOutputfile As New System.Xml.XmlTextWriter("c:\Simplexml.xml", System.Text.Encoding.UTF8) xmlproc = xmldoc.CreateXmlDeclaration("1.0", "", "") xmldoc.AppendChild(xmlproc) xmlroot = xmldoc.CreateElement("invoice") xmlAttri = xmldoc.CreateAttribute("xmlns") xmlAttri.Value = "http://www.test.info" xmlroot.Attributes.Append(xmlAttri) xmlAttri = xmldoc.CreateAttribute("xmlns:xsi") xmlAttri.Value = "http://www.w3.org/2001/XMLSchema-instance" xmlroot.Attributes.Append(xmlAttri) xmlAttri = xmldoc.CreateAttribute("schemaLocation") xmlAttri.Value = "http://NamespaceTest.com/Purchase test_xml_feed.xsd" xmlroot.Attributes.Append(xmlAttri) xmlchild = xmldoc.CreateElement("provider_ref") xmlchild.InnerText = "1234" xmlroot.AppendChild(xmlchild) xmlchild = xmldoc.CreateElement("supplier_name") xmlchild.InnerText = "A Supplier" xmlroot.AppendChild(xmlchild) xmlchild = xmldoc.CreateElement("period") xmlchild.InnerText = "2008-05-04" xmlroot.AppendChild(xmlchild) xmlchild = xmldoc.CreateElement("invoice_number") xmlchild.InnerText = "000000001" xmlroot.AppendChild(xmlchild) xmlroot.AppendChild(xmlchild) xmldoc.AppendChild(xmlroot) xmldoc.WriteTo(xmlOutputfile) xmlOutputfile.Close() End Sub




Reply With Quote