StealthRT
08-10-2009, 10:57 PM
Hey all, i am having problems reading an xml file off apples server. Problem seems to be that within the same list node, it has duplicate names. Here is part of the XML file im referring too:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OS</key>
<dict>
<key>BuildVersion</key>
<string>8N9840</string>
<key>UpdateURL</key>
<string>http://mesu.apple.com/data/file.dmg</string>
<key>Version</key>
<string>10.7</string>
<key>DownloadSize</key>
<integer>165855521</integer>
</dict>
and here is the code i am currently using to gather the information needed.
Private Sub LoadData(strXML As String)
Dim objDoc As MSXML2.DOMDocument40
Dim objNodeList As IXMLDOMNodeList
Dim objSubNodeList As MSXML2.IXMLDOMNodeList
Dim objNode As MSXML2.IXMLDOMNode
Dim objSubNode As MSXML2.IXMLDOMNode
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
objDoc.Load strXML
If objDoc.parseError.errorCode = 0 Then
If objDoc.readyState = 4 Then
DoEvents
End If
Else
MsgBox "Error"
Exit Sub
End If
Set objNodeList = objDoc.selectNodes("//dict")
For Each objNode In objNodeList
Set objSubNodeList = objNode.selectNodes("dict")
For Each objSubNode In objSubNodeList
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("integer").Text
Next objSubNode
Next objNode
End Sub
Private Sub Command1_Click()
LoadData "http://xxxxx.com"
End Sub
The code works just fine but the output is incorrect for what i am looking for:
BuildVersion
8N9840
BuildVersion
8N9840
BuildVersion
8N9840
BuildVersion
165855521
Because of the duplicate names (key, string, key, string..) it doesn't seem to be able to gather all the needed info i am looking for. I'm looking to get this:
BuildVersion
8N9840
UpdateURL
http://mesu.apple.com/data/file.dmg
Version
10.7
DownloadSize
165855521
Is there anyway to get those values other than just the first 2 key and string?
Thanks for your time!
David
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OS</key>
<dict>
<key>BuildVersion</key>
<string>8N9840</string>
<key>UpdateURL</key>
<string>http://mesu.apple.com/data/file.dmg</string>
<key>Version</key>
<string>10.7</string>
<key>DownloadSize</key>
<integer>165855521</integer>
</dict>
and here is the code i am currently using to gather the information needed.
Private Sub LoadData(strXML As String)
Dim objDoc As MSXML2.DOMDocument40
Dim objNodeList As IXMLDOMNodeList
Dim objSubNodeList As MSXML2.IXMLDOMNodeList
Dim objNode As MSXML2.IXMLDOMNode
Dim objSubNode As MSXML2.IXMLDOMNode
Set objDoc = New MSXML2.DOMDocument
objDoc.async = False
objDoc.Load strXML
If objDoc.parseError.errorCode = 0 Then
If objDoc.readyState = 4 Then
DoEvents
End If
Else
MsgBox "Error"
Exit Sub
End If
Set objNodeList = objDoc.selectNodes("//dict")
For Each objNode In objNodeList
Set objSubNodeList = objNode.selectNodes("dict")
For Each objSubNode In objSubNodeList
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("string").Text
Debug.Print objSubNode.selectSingleNode("key").Text
Debug.Print objSubNode.selectSingleNode("integer").Text
Next objSubNode
Next objNode
End Sub
Private Sub Command1_Click()
LoadData "http://xxxxx.com"
End Sub
The code works just fine but the output is incorrect for what i am looking for:
BuildVersion
8N9840
BuildVersion
8N9840
BuildVersion
8N9840
BuildVersion
165855521
Because of the duplicate names (key, string, key, string..) it doesn't seem to be able to gather all the needed info i am looking for. I'm looking to get this:
BuildVersion
8N9840
UpdateURL
http://mesu.apple.com/data/file.dmg
Version
10.7
DownloadSize
165855521
Is there anyway to get those values other than just the first 2 key and string?
Thanks for your time!
David