-
January 27th, 2012, 10:18 PM
#1
[RESOLVED] XML Woes
I've been banging my head for a while now and just can't seem to figure out what the problem is here. I have not really worked with XML much and thought it would be good to do some work with it in order to have a better understanding. I decided to write a little program to allow editing a game file. I found some examples on the net of basic XML functions and tried to use one of them in my program.
The Xml file I am working with is huge so I will show just enough to give an idea of the format.
Code:
<?xml version="1.0"?>
<Proto version ='2'>
<Unit id ='0' name ='InvisibleProjectile'>
<DBID>20</DBID>
<DisplayNameID>22885</DisplayNameID>
<Flag>NoIdleActions</Flag>
<Flag>NonCollideable</Flag>
<Flag>DestroyProjectile</Flag>
<Flag>DoNotCreateUnitGroupAutomatically</Flag>
<Flag>NoBloodOnDeath</Flag>
</Unit>
<Unit id ='1' name ='Cannonball'>
<DBID>21</DBID>
<DisplayNameID>22888</DisplayNameID>
<UnitType>EmbellishmentClass</UnitType>
<Flag>NoHPBar</Flag>
<Flag>NonAutoFormedUnit</Flag>
<Flag>DoNotShowOnMiniMap</Flag>
</Unit>
</Proto>
This is the code I tried most recently
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_xmld = New XmlDocument()
m_xmld.Load("C:\aoework\protox.xml")
m_nodelist = m_xmld.SelectNodes("/proto/unit")
For Each m_node In m_nodelist
TextBox1.Text += m_node.Name & vbCrLf
Next
Catch errorVariable As Exception
TextBox1.Text = errorVariable.ToString()
End Try
End Sub
I have tried different text in the select nodes portion, such as "proto" "/proto" and the above but in every case I get a count of 0 on the node list and nothing is displayed in my textbox.
Each <Unit> is roughy 30-35 lines and the file has over 59k lines of units so clearly the count should be rather high but always 0.
Any idea what I am doing wrong here.
btw The above is using VB 2005, I also tried in VB 2008 before but same results.
Last edited by DataMiser; January 27th, 2012 at 10:23 PM.
Always use [code][/code] tags when posting code.
-
January 27th, 2012, 10:53 PM
#2
Re: [RESOLVED] XML Woes
Apparently the select is Case Sensitive
Always use [code][/code] tags when posting code.
-
January 28th, 2012, 05:26 AM
#3
Re: [RESOLVED] XML Woes
Originally Posted by DataMiser
Apparently the select is Case Sensitive
Indeed it is. That really sucks about XML. I have run into this same problem some time ago and wasn't impressed finding out that it was case sensitive. Good luck though!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|