Adding a namespace to an xml file

Discussion in 'ASP General' started by Shawn, Jan 22, 2004.

  1. Shawn

    Shawn Guest

    Hi!
    I've spent several hours finding a solution to this problem without any
    luck. Hopefully someone here can provide me with an answer.

    When I run this code I get an error saying: "Reference to undeclared
    namespace prefix: 'esu'."
    My question is simple: How do I add a namespace??
    This is what the namespace should look like:
    <esu:institusjoner xmlns:esu="http://www.utdanning.no/schema/institusjon/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.utdanning.no/schema/institusjon/
    C:\schemas\schema_institusjon.xsd">

    Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")

    Set root = xmldoc.createNode("element", "esu:myroot", "")
    xmldoc.appendChild(root)

    Set node_1 = xmldoc.createNode("element", "esu:user", "")
    xmldoc.documentElement.appendChild(node_1)

    Set node_2 = xmldoc.createNode("element", "esu:id", "")
    node_2.Text = "1"
    node_1.appendChild(node_2)

    Set node_3 = xmldoc.createNode("element", "esu:name", "")
    node_3.Text = "Shawn"
    node_1.appendChild(node_3)

    xmldoc.save(server.mappath("xml.xml"))


    Thanks,
    Shawn
    Shawn, Jan 22, 2004
    #1
    1. Advertising

  2. "Shawn" <> wrote in message
    news:...
    > Hi!
    > I've spent several hours finding a solution to this problem without

    any
    > luck. Hopefully someone here can provide me with an answer.
    >
    > When I run this code I get an error saying: "Reference to undeclared
    > namespace prefix: 'esu'."
    > My question is simple: How do I add a namespace??
    > This is what the namespace should look like:
    > <esu:institusjoner

    xmlns:esu="http://www.utdanning.no/schema/institusjon/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    > xsi:schemaLocation="http://www.utdanning.no/schema/institusjon/
    > C:\schemas\schema_institusjon.xsd">
    >
    > Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    >
    > Set root = xmldoc.createNode("element", "esu:myroot", "")
    > xmldoc.appendChild(root)
    >
    > Set node_1 = xmldoc.createNode("element", "esu:user", "")
    > xmldoc.documentElement.appendChild(node_1)
    >
    > Set node_2 = xmldoc.createNode("element", "esu:id", "")
    > node_2.Text = "1"
    > node_1.appendChild(node_2)
    >
    > Set node_3 = xmldoc.createNode("element", "esu:name", "")
    > node_3.Text = "Shawn"
    > node_1.appendChild(node_3)
    >
    > xmldoc.save(server.mappath("xml.xml"))


    http://msdn.microsoft.com/library/en-us/xmlsdk/htm/xml2nd_pro_v4_0tyr.asp
    Chris Hohmann, Jan 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Èý¹â
    Replies:
    1
    Views:
    567
    William F. Robertson, Jr.
    Jul 29, 2003
  2. Replies:
    0
    Views:
    5,129
  3. Anonymous
    Replies:
    3
    Views:
    531
    Ron Natalie
    Aug 18, 2003
  4. Replies:
    5
    Views:
    1,220
  5. Erik Wasser
    Replies:
    5
    Views:
    451
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page