Sign in to follow this  
Followers 0
rejectpenguin

Parse XML File

6 posts in this topic

Hey, is there a non complicated way to parse an xml file? If I use _INetGetSource it gives me the html of the file but not the xml.

Here is the file im trying to parse: http://www.wowarmory.com/character-sheet.xml?r=Anub%27arak&n=Lovepenguin

Share this post


Link to post
Share on other sites



#include <_XMLDomWrapper.au3>
#include <File.au3>

Global $oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://www.wowarmory.com/character-sheet.xml?r=Anub%27arak&n=Lovepenguin", 0)
$oXML.Send

Global $sFile = _TempFile(@TempDir, '~', '.xml')
FileWrite($sFile, $oXML.responseText)

If _XMLFileOpen($sFile) Then
    Local $aRet = _XMLGetChildNodes('//*')
    If Not @error Then
        For $i = 1 To $aRet[0]
            ConsoleWrite($aRet[$i] & @LF)
        Next
    EndIf
EndIf

FileDelete($sFile)

http://www.zvon.org/xxl/XPathTutorial/Output/example1.html

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <_XMLDomWrapper.au3>
#include <File.au3>

Global $oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://www.wowarmory.com/character-sheet.xml?r=Anub%27arak&n=Lovepenguin", 0)
$oXML.Send

Global $sFile = _TempFile(@TempDir, '~', '.xml')
FileWrite($sFile, $oXML.responseText)

If _XMLFileOpen($sFile) Then
    Local $aRet = _XMLGetChildNodes('//*')
    If Not @error Then
        For $i = 1 To $aRet[0]
            ConsoleWrite($aRet[$i] & @LF)
        Next
    EndIf
EndIf

FileDelete($sFile)

http://www.zvon.org/xxl/XPathTutorial/Output/example1.html

Thanks for the quick response and code.. I don't quite understand the code you have posted tho but I'm sure I can figure it out with a little help..

How can I get info from the XML file such as for instance level (which is equal to 80). Or profession. I'm not quite sure what to do.

Is there a way I can just parse the XML like I would do a text file or html source?

Edited by rejectpenguin

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for the quick response and code.. I don't quite understand the code you have posted tho but I'm sure I can figure it out with a little help..

How can I get info from the XML file such as for instance level (which is equal to 80). Or profession. I'm not quite sure what to do.

Is there a way I can just parse the XML like I would do a text file or html source?

Any help on how to reference I guess the node professions? I don't have much experience.

Ive tried Local $aRet = _XMLGetValue('characterInfo/character/battleGroup')

but think im doing something horribly wrong.

Edited by rejectpenguin

Share this post


Link to post
Share on other sites

#include <_XMLDomWrapper.au3>
#include <File.au3>

Global $oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://www.wowarmory.com/character-sheet.xml?r=Anub%27arak&n=Lovepenguin", 0)
$oXML.Send

Global $sFile = _TempFile(@TempDir, '~', '.xml')
FileWrite($sFile, $oXML.responseText)

If _XMLFileOpen($sFile) Then
    Local $sLvl = _XMLGetAttrib('./characterInfo/character', 'level')
    ConsoleWrite($sLvl & @LF)
EndIf

FileDelete($sFile)

I've added the XPath link to help you using examples of how to use it. Here is another one

Share this post


Link to post
Share on other sites

#include <_XMLDomWrapper.au3>
#include <File.au3>

Global $oXML = ObjCreate("Microsoft.XMLHTTP")
$oXML.Open("GET", "http://www.wowarmory.com/character-sheet.xml?r=Anub%27arak&n=Lovepenguin", 0)
$oXML.Send

Global $sFile = _TempFile(@TempDir, '~', '.xml')
FileWrite($sFile, $oXML.responseText)

If _XMLFileOpen($sFile) Then
    Local $sLvl = _XMLGetAttrib('./characterInfo/character', 'level')
    ConsoleWrite($sLvl & @LF)
EndIf

FileDelete($sFile)

I've added the XPath link to help you using examples of how to use it. Here is another one

Thanks so much man.. You've helped me alot!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0