Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Adding a namespace to an xml file

Reply
Thread Tools

Adding a namespace to an xml file

 
 
Shawn
Guest
Posts: n/a
 
      01-22-2004
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/"
xmlnssi="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


 
Reply With Quote
 
 
 
 
Chris Hohmann
Guest
Posts: n/a
 
      01-23-2004
"Shawn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/"
> xmlnssi="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...ro_v4_0tyr.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Adding namespace prefix to elements read from external file johanneskrueger@gmx.net XML 5 02-11-2007 07:43 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
ERROR CS0234: The type or namespace name 'DataAccessHelper' does not exist in the namespace 'BCC' (are you missing an assembly reference?) li.eddie@gmail.com ASP .Net 0 01-06-2006 11:31 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. ASP .Net 1 07-29-2003 04:31 PM



Advertisments