Jump to content

Recommended Posts

Posted

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

Posted

#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

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
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
Posted

#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

Posted

#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!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...