Jump to content
  • Advertisement
Sign in to follow this  
assainator

[.net] vb xml problem

This topic is 3343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

heey all, i'm having a problem with xml in visual basic.net it's some kind of project file that has to save the path's to the files that are in the project. The project file is a simple xml file. I can read the settingsfile without a problem but i'm having a problem with writing it. the code loads a basic settings file, and starts to edit some parameters, in this case the interface files. It first puts amount of files into the file(ItemList.Items.Count(wich is a listbox)) then it loops trough each file, it creates a new node, and puts it behind the previous. A node looks like this: <file_1>example.itf</file_1> the problem now is that I get a runtime error that says: "NullReferenceExeption was unhandled." But i can't see what is null/nothing. the code:
                    Dim xmlDoc As New System.Xml.XmlDataDocument
                    Dim xmlNode As System.Xml.XmlNodeList

                    xmlDoc.Load("base.xml")
                    ''''''''''''''''''''''''''''''''''
                    '' put the inteface file path's into the file
                    ''''''''''''''''''''''''''''''''''
                    xmlNode = xmlDoc.GetElementsByTagName("interfaceFiles")
                    Dim xmlFileNode As System.Xml.XmlNode
                    Dim PreviousXmlFileNode As System.Xml.XmlNode

                    xmlNode.Item(0).ChildNodes(0).InnerText.Replace(" ", ItemList.Items.Count)
                    Dim xmlTotalInterfaceCountNode As System.Xml.XmlNode = xmlNode.Item(0).ChildNodes(0)

                    For fileNr As Integer = 0 To ItemList.Items.Count
                        PreviousXmlFileNode = xmlFileNode
                        xmlFileNode.Value = "<file_" & fileNr & ">" & ItemList.Items(fileNr).ToString() & "</file_" & fileNr & ">"
                        If fileNr = 0 Then
                            xmlNode.Item(0).InsertAfter(xmlFileNode, xmlTotalInterfaceCountNode)
                        End If
                        xmlNode.Item(0).InsertAfter(xmlFileNode, PreviousXmlFileNode)
                    Next

thanks in advance, assainator

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!