Jump to content

Recommended Posts

I'm trying to relearn the XML udf and etrieve information from:

"http://dev.virtualearth.net/REST/v1/Traffic/Incidents/40.65,-73.55,40.95,-73.95?&output=xml&key=AkjlIWX4DBF05t0H8vfLeT5XbDQCc1h4jcQ8FSnmamKqDna_Nq-VJNp9ZNCIThzw"

My issue is...I believe..is I don't have any names or ID in the result. How can I retrieve the information and plug them into an array?

I even keep getting errors when I simply try to get a node count, so I'm lost.

$Xml = _XMLFileOpen("http://dev.virtualearth.net/REST/v1/Traffic/Incidents/40.65,-73.55,40.95,-73.95?&output=xml&key=AkjlIWX4DBF05t0H8vfLeT5XbDQCc1h4jcQ8FSnmamKqDna_Nq-VJNp9ZNCIThzw")
$count = _XMLGetNodeCount ("//Resources/*")
Thanks. Edited by Champak
Link to post
Share on other sites

Your html source is not a file.  You have to grab the xml, and then throw it into a file to use...or, there is another method to load strings into the xml object...you will still need to grab the source first:

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadxml($string)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to post
Share on other sites

I did notice that every example was from a local file, but I was unsuccessful in saving the page as a XML file. I used all the IERead functions and filewrite, so I gave up on that. Then I came across an example here where someone was reading it directly from the web page and their example was working with no problem just like how I have it above and I tried it and it worked (when I get home I'll find it and post it, because I can't find it now.). So since theirs worked, I'm wondering why mine won't.

I'll look back at grabbing it and saving it as well.

Link to post
Share on other sites

I never navigated to the page, but if it only includes your xml, this would probably work (add in your proper ie object):

$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.loadxml(_IEBodyReadHTML($oIE))
ConsoleWrite($oXML.xml & @CRLF)

If it's pure xml, then you will have the full output of the xml in the consolewrite.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to post
Share on other sites

 

;_SetDebug (True);show debug messages via console write
#include <_XMLDomWrapper.au3>
#include <Inet.au3>
#include <Array.au3>
;#RequireAdmin

$Xml = ""
$Xml = _XMLFileOpen("http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/driver/NFSDREW/cars?shard=Apex")
;$Xml = _XMLFileOpen(http://dev.virtualearth.net/REST/v1/Traffic/Incidents/40.65,-73.55,40.95,-73.95?&output=xml&key=DELETED)


$count = _XMLGetNodeCount ("//worldCar/*")
;$count = _XMLGetNodeCount ("//Resource/*")

MsgBox(0,0,$count)

Dim $aAttrName[1], $aAttrValue[1], $node
for $x= 1 to $count
$node = _XMLGetAllAttrib ("/list/*["&$x-1&"]",$aAttrName,$aAttrValue )
$node1 = _XMLGetAllAttrib ("/list/*["&$x-1&"]/*",$aAttrName,$aAttrValue )

_ArrayDisplay($node," worldCar Value")
_ArrayDisplay($node1," physicsProfile Value")
;_ArrayDisplay($aAttrName,"Attrib Names")
;_ArrayDisplay($aAttrValue,"Attrib Value")


$node = _XMLGetAttrib("/list/*["&$x-1&"]/*","name",'[@id='&$x&']')
MsgBox(0,"Name Where Id="&$x,$node)
if @error then ExitLoop
Next

Exit

 

Here's the example I mentioned. It is being read directly from the website and it works with no issue. Now with the page I'm trying to access, I can't get anything out of it except a node count (when converting it to a string first) when I do _XMLGetNodeCount("//*"). As far as the IE function to use, its actually _IEDocReadHTML which spits out actual HTML tags. I guess I could use that in order to cycle through this and get the info I need with stringbetween, but this thing seemed cleaner and faster.

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

    No registered users viewing this page.

×
×
  • Create New...