473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding a namespace to an xml file

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
Jul 19 '05 #1
1 1702
"Shawn" <bo********@hotmail.com> wrote in message
news:uM**************@TK2MSFTNGP12.phx.gbl...
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...ro_v4_0tyr.asp
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: LuAnn Bradford | last post by:
I have read the messages about adding namespaces, but have not found how to do so when using an XPathDocument instead of an XmlDocument. I have an application that writes a dataset using...
1
by: Bill Geake | last post by:
I am successfully serializing to XML from a class like this: private static void CreateXML() { testClass c = new testClass(); c.stringElement = "data1"; c.stringElement2 = "data2"; ...
5
by: Angel | last post by:
Is there some way to add a C-header file into a C# project? The problem is that this .h file contains several complex structures (over 20) that are used by some unmanaged code. These functions...
9
by: Ben Dewey | last post by:
Project: ---------------------------- I am creating a HTTPS File Transfer App using ASP.NET and C#. I am utilizing ActiveDirectory and windows security to manage the permissions. Why reinvent...
3
by: Davinci_Jeremie | last post by:
After creating a namespace in one file how would I add to that a new object in the same namespace in a diffrent file? IE FILE1 contains namespace FINANCE FILE2 has object that want to exist in...
2
by: Chris Wertman | last post by:
I am rustier than I thought when it comes to Visual Studio and VB.NET for the last year I have been writing only ASP.NET pages in inline code and well I kinda forget how to add a reference , well...
4
by: glebur | last post by:
Hi, I'm trying to create a web service client in C# but I get stuck at one of the first steps. When adding a Web reference to the Visual Studio project; I get this error (this is a translation,...
5
by: Water Cooler v2 | last post by:
I know that we can add a single name value entry in app.config or web.config in the configuration/configSettings/appSettings section like so: <add key="key" value="value" /> Question: I want...
28
by: Ilias Lazaridis | last post by:
I understand that I can use __metaclass__ to create a class which modifies the behaviour of another class. How can I add this metaclass to *all* classes in the system? (In ruby I would alter...
5
by: johanneskrueger | last post by:
Hello, I'm currently using <xsl:copy-of select="document(...)/svg:svg"/to embed an SVG file into an XHTML file. I already defined the SVG namespace and assigned svg as its prefix in my XSLT 1.0...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.