evilbird2001
New member
- Joined
- Dec 20, 2012
- Messages
- 3
- Programming Experience
- 1-3
Im just recently getting back into programming vb after being away for many years. Im currently working on a project that requires i insert or append data to a specific node in an xml file.
When i run this bit of code.
Dim XMLDom As New XmlDocument()
XMLDom.Load("C:\Users\PatDaRat\Dropbox\WindowsApplication18\test.xml")
Dim newXMLNode As XmlNode = XMLDom.SelectSingleNode("rule")
Dim childNode As XmlNode = XMLDom.CreateNode(XmlNodeType.Element, "one-of", "")
Dim newAttribute As XmlAttribute = XMLDom.CreateAttribute("item3", TextBox1.Text, "")
childNode.Attributes.Append(newAttribute)
newXMLNode.AppendChild(childNode)
I get this error with line 7 highlighted.
"An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication18.exe
Additional information: Object reference not set to an instance of an object."
I've been searching for quite awhile and staring this seeming simply piece of code down, and i simply cant come to a conclusion as to why im getting this error.
I would greatly appreciate an advice anyone might have to offer.
Thanks in advance for your help!
When i run this bit of code.
Dim XMLDom As New XmlDocument()
XMLDom.Load("C:\Users\PatDaRat\Dropbox\WindowsApplication18\test.xml")
Dim newXMLNode As XmlNode = XMLDom.SelectSingleNode("rule")
Dim childNode As XmlNode = XMLDom.CreateNode(XmlNodeType.Element, "one-of", "")
Dim newAttribute As XmlAttribute = XMLDom.CreateAttribute("item3", TextBox1.Text, "")
childNode.Attributes.Append(newAttribute)
newXMLNode.AppendChild(childNode)
I get this error with line 7 highlighted.
"An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication18.exe
Additional information: Object reference not set to an instance of an object."
I've been searching for quite awhile and staring this seeming simply piece of code down, and i simply cant come to a conclusion as to why im getting this error.
I would greatly appreciate an advice anyone might have to offer.
Thanks in advance for your help!