Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. change attributes whitin XML

change attributes whitin XML

Scheduled Pinned Locked Moved XML / XSL
xmldatabasehelpquestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3749986
    wrote on last edited by
    #1

    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";
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups