TVMiller 0 Posted August 6, 2015 Share Posted August 6, 2015 Looked and copy/paste several variations from articles I've read and the key sticking pointing is that I don't under stand how to define the path in the xml file.XML is a weather page http://forecast.weather.gov/MapClick.php?lat=34.3855&lon=-118.514&unit=0&lg=english&FcstType=dwmlGoal for now is just to learn how to clipput the current temperature.Thanks in advance.<data type="current observations"> <parameters applicable-location="point1"> <temperature type="apparent" units="Fahrenheit" time-layout="k-p1h-n1-1"> <value>89</value>#include <_XMLDomWrapper.au3> #include <File.au3> Global $oXML = ObjCreate("Microsoft.XMLHTTP") $oXML.Open("GET", "http://forecast.weather.gov/MapClick.php?lat=34.3855&lon=-118.514&unit=0&lg=english&FcstType=dwml", 0) $oXML.Send Global $sFile = _TempFile(@TempDir, '~', '.xml') FileWrite($sFile, $oXML.responseText) $dataName = "current observations" $tempName = "apparent" If _XMLFileOpen($sFile) Then Local $sLvl = _XMLGetAttrib('/data[@type="' & $dataName & '"]/parameters/temperature[@type="' & $tempName & '"]/value', '') ClipPut($sLvl) EndIf FileDelete($sFile) Link to post Share on other sites
Xameleon 0 Posted August 7, 2015 Share Posted August 7, 2015 (edited) Hi, maybe this would be a little shorter sample.Opt("MustDeclareVars",1) Dim $oXmlParser = ObjCreate("MSXML2.DOMDOcument") With $oXmlParser .Async = False .Load("http://forecast.weather.gov/MapClick.php?lat=34.3855&lon=-118.514&unit=0&lg=english&FcstType=dwml") Dim $sTemperature = .SelectSingleNode("//data[@type=""current observations""]/parameters/temperature[@type=""apparent""]/value").text MsgBox(64,"Temperature request","Current temperature is " & $sTemperature) EndWith Edited August 7, 2015 by Xameleon Link to post Share on other sites
TVMiller 0 Posted August 8, 2015 Author Share Posted August 8, 2015 Hi, maybe this would be a little shorter sample.Opt("MustDeclareVars",1) Dim $oXmlParser = ObjCreate("MSXML2.DOMDOcument") With $oXmlParser .Async = False .Load("http://forecast.weather.gov/MapClick.php?lat=34.3855&lon=-118.514&unit=0&lg=english&FcstType=dwml") Dim $sTemperature = .SelectSingleNode("//data[@type=""current observations""]/parameters/temperature[@type=""apparent""]/value").text MsgBox(64,"Temperature request","Current temperature is " & $sTemperature) EndWith Link to post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now