change attributes whitin XML
-
Hello guys, I am having a problem with the order or the attributes with xml in vb. I get the following header:
<?xml version="1.0" ?>
- <tvtnl:spotPlanningFile xsi:schemaLocation="http://www.tvtimes.nl/sko/schema/20010910" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tvtnl="http://www.tvtimes.nl/sko/schema/20010910">
and I need:
<?xml version="1.0" ?>
- <tvtnl:spotPlanningFile xmlns:tvtnl="http://www.tvtimes.nl/sko/schema/20010910" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.tvtimes.nl/sko/schema/20010910">
notice the first and the last attribute.(they need to be switched) my code to come to this:
Dim xmlDoc As New Xml.XmlDocument
Dim xmlDeclaration As Xml.XmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "", "")'root
Dim rootNode As Xml.XmlElement = xmlDoc.CreateElement("tvtnl", "spotPlanningFile", "http://www.tvtimes.nl/sko/schema/20010910")
xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement)Dim att As Xml.XmlAttribute = xmlDoc.CreateAttribute("xsi:schemaLocation", "http://www.tvtimes.nl/sko/schema/20010910")
att.Value = "http://www.tvtimes.nl/sko/schema/20010910"
rootNode.SetAttributeNode(att)rootNode.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
xmlDoc.AppendChild(rootNode)
what am i doing wrong? got any tips?? here is something i already tried:
Dim xmlDeclaration As Xml.XmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "", "") 'root Dim rootNode As Xml.XmlElement = xmlDoc.CreateElement("tvtnl", "spotPlanningFile", "http://www.tvtimes.nl/sko/schema/20010910") xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement) 'Dim xmlmanager As New Xml.XmlNamespaceManager(xmlDoc.NameTable) 'xmlmanager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance") Dim att As Xml.XmlAttribute = xmlDoc.CreateAttribute("xsi:schemaLocation", "http://www.tvtimes.nl/sko/schema/20010910") att.Value = "http://www.tvtimes.nl/sko/schema/20010910" rootNode.SetAttributeNode(att) 'XmlAttribute att = doc.CreateAttribute("xsi", "noNamespaceSchemaLocation", "http://www.w3.org/2001/XMLSchema-instance"); 'att.Value = "TestCaseSchema\_03.xsd";