I have an xml file structured thusly:
xml Code:
<?xml version="1.0" encoding="us-ascii" ?> <signaturelist> <signature> <name>Final Fantasy VI Advance</name> <editor>FFVIAdvance.dll</editor> <sram> <start>7936</start> <length>32</length> <string>46494E414C2046414E544153592056492020202020414456414E434520202020</string> </sram> <vba> <start>4</start> <length>16</length> <string>464636414456414E43450000425A3645</string> </vba> </signature> <signature> <name>Castlevania: Circle of the Moon</name> <editor>CastlvaniaCotM.dll</editor> <sram> <start>0</start> <length>11</length> <string>44524143554C4120414742</string> </sram> <vba> <start>4</start> <length>16</length> <string>44524143554C41204147423141414D45</string> </vba> </signature> </signaturelist>
If the structure is wrong then let me know, I made it using Expression Web.
I have looked at examples of parsing xml files and have the following code:
vb.net Code:
Dim m_xmld As New Xml.XmlDocument m_xmld.LoadXml(My.Resources.signatures) Dim start_nodes As Xml.XmlNodeList = m_xmld.GetElementsByTagName("start") Dim length_nodes As Xml.XmlNodeList = m_xmld.GetElementsByTagName("length") Dim string_nodes As Xml.XmlNodeList = m_xmld.GetElementsByTagName("string") Dim i As Integer = 0 Do If Read.HexString(CInt(start_nodes(i).Value), CInt(length_nodes(i).Value)) = string_nodes(i).Value Then ' extra code here i += 1 End If Loop While i < start_nodes.Count
basically the HexString function will read bytes from my internal buffer starting at "start" and reading "length" bytes. It then returns a string containing the bytes read. If it is equal to "string" then the correct signature is read.
My problem:
I cannot figure out how to know if I am in the "sram" or "vba" node or even which signature I am reading from (so I can get the value of "name" and "editor"). I could count the number of signatures I have read through but they will not be in any concrete order.
Previously, I have used a line delimited text file with each signature on it's own line. Each property was seperated by a "|" character and I would split the line and check the signature like that.
I wanted to instead use xml. Thanks, Troy.




Reply With Quote