473,503 Members | 3,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a XML Document with asp.net 2.0

How can i create a XMLDocument??

This is what i have:

Dim objNode As XmlNode

Dim objAttrib As XmlAttribute
objNode = objXML.DocumentElement("Person")

objAttrib = objXML.CreateAttribute("PERSONID")
objAttrib.Value = "p7"
objNode.Attributes.SetNamedItem(objAttrib)
objXML.DocumentElement.AppendChild(objNode)

Then i get an error like this:

System.NullReferenceException: Object reference not set to an instance
of an object.

Can somebody help me out?

Aug 21 '06 #1
3 4811


Dikkuuhh wrote:
How can i create a XMLDocument??
Dim xmlDoc As New System.Xml.XmlDocument()

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 21 '06 #2
Now this is my code:

Dim objXML As New System.Xml.XmlDocument()
Dim objNode As XmlNode
Dim objAttrib As XmlAttribute
objNode = objXML.DocumentElement("Person")

objAttrib = objXML.CreateAttribute("PERSONID")
objAttrib.Value = "p7"
objNode.Attributes.SetNamedItem(objAttrib)
objXML.DocumentElement.AppendChild(objNode)

But i`m still getting the same error....
Martin Honnen wrote:
Dikkuuhh wrote:
How can i create a XMLDocument??

Dim xmlDoc As New System.Xml.XmlDocument()

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 22 '06 #3


Dikkuuhh wrote:

Dim objXML As New System.Xml.XmlDocument()
This line creates the XmlDocument instance but it is empty, you can
either load existing XML into it with the Load method to load from a URL
or stream (or the LoadXml method if you have a string with the XML
markup) or you need to populate the document with nodes by first
creating them and inserting them as needed e.g. (watch out for line
breaks VB does not allow but the news posting might have)

Dim rootElement As XmlElement =
objXML.CreateElement("some-element-name")
Dim someElement as XmlElement =
objXML.CreateElement("another-element-name")
someElement.SetAttribute("attribute-name", "attribute value")
rootElement.AppendChild(someElement)
objXML.AppendChild(rootElement)

objXML.Save("file.xml")

If you still have problems then I suggest microsoft.public.dotnet.xml is
a better place than comp.text.xml.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 22 '06 #4

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

Similar topics

2
13477
by: obsidian8 | last post by:
Hi All, I have looked around for an answer to this question, but haven't found one as of yet. I'm trying to use javascript to dynamically create raido buttons. I am able to create them easily...
3
9120
by: takarimasu | last post by:
How can i create an input object (text area,select) at runtime ? B.
3
5364
by: Richard Fritzler | last post by:
I was given the task of designing a complete web based document prep system. In simplest terms (using a msword explanation) create a database of merge fields, and a library of templates. Allow the...
3
479
by: di | last post by:
I have a Access Database, and I would like to create a word document that (preferable would filter)links to ACCESS table or query. I would like to print the word document on the filtered record...
3
12342
by: sloesch | last post by:
I am working with VS.net 2003, framework 1.1, developing with VB.net, and ASP.net, and I would like to know how you can create a dynamic hyperlink on the fly to a document stored in a SQL database?...
0
3195
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
4
12412
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
10
3940
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
4
8259
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
14
5155
RMWChaos
by: RMWChaos | last post by:
Firebug is reporting "too much recursion" when I attempt to create a child element in a parent that doesn't exist yet. The script should automatically create the missing parent before going on to...
0
7192
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
7064
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
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
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...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.