
Re: Help with getting XML into Variables
i am still trying with this but get an error. and would really like to get this going
Thanks
if you want the IP to do a live test let me know.
Result:
error "System Events got an error: Can’t get XML element \"Probes\" of contents of XML file \"Macintosh HD:Usersritesktop:ApexData.xml\"." number -1728 from XML element "Probes" of contents of XML file "Macintosh HD:Users:rtesktop:ApexData.xml"here is my latest code.
set gatewayAddress to "http://7x.1xx.9x.xxx"
set thePort to "1001"
set output_path to "~/Desktop/ApexData.xml"
set fileURL to gatewayAddress & ":" & thePort & "/cgi-bin/status.xml"
do shell script "curl " & fileURL & " -o " & output_path
set XMLfile to "~/Desktop/ApexData.xml"
tell application "System Events"
set xml_data to contents of XML file XMLfile
tell xml_data to set probes to XML element "probes"
tell xml_data to set probe to XML element "probe" of probes
tell xml_data to set temperature to XML element "value" of probe
set tanktemp to value of temperature
tell application "IndigoServer"
set value of variable "Temp" to tanktemp as integer
end tell
end tell
here is my XML file.
- Code: Select all
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<status software="4.12L_2A12" hardware="1.0">
<hostname>apex</hostname>
<serial>AC4:04376</serial>
<timezone>-8</timezone>
<date>05/08/2012 11:29:58</date>
<power>
<failed>04/26/2012 08:55:46</failed>
<restored>04/26/2012 08:56:20</restored>
</power>
<probes>
<probe>
<name>Temp</name>
<value>78.4</value>
<type>Temp</type>
</probe>
<probe>
<name>pH</name>
<value>8.23</value>
<type>pH</type>
</probe>
<probe>
<name>Amp_3</name>
<value>0.0</value>
<type>Amps</type>
</probe>
</probes>
<outlets>
<outlet>
<name>zSndAlm_I6</name>
<outputID>0</outputID>
<state>AOF</state>
<deviceID>base_Alarm</deviceID>
</outlet>
<outlet>
<name>zSndWrn_I7</name>
<outputID>1</outputID>
<state>AOF</state>
<deviceID>base_Warn</deviceID>
</outlet>
<outlet>
<name>zEmailAlm_I5</name>
<outputID>2</outputID>
<state>AOF</state>
<deviceID>base_email</deviceID>
</outlet>
<outlet>
<name>HighPump</name>
<outputID>3</outputID>
<state>ON</state>
<deviceID>3_1</deviceID>
</outlet>
<outlet>
<name>Skimmer</name>
<outputID>4</outputID>
<state>ON</state>
<deviceID>3_2</deviceID>
</outlet>
<outlet>
<name>LowPump</name>
<outputID>5</outputID>
<state>ON</state>
<deviceID>3_3</deviceID>
</outlet>
<outlet>
<name>Heater</name>
<outputID>6</outputID>
<state>AOF</state>
<deviceID>3_4</deviceID>
</outlet>
<outlet>
<name>Vortech</name>
<outputID>7</outputID>
<state>AON</state>
<deviceID>3_5</deviceID>
</outlet>
<outlet>
<name>Fan</name>
<outputID>8</outputID>
<state>AOF</state>
<deviceID>3_6</deviceID>
</outlet>
<outlet>
<name>Reactor</name>
<outputID>9</outputID>
<state>OFF</state>
<deviceID>3_7</deviceID>
</outlet>
<outlet>
<name>Radion</name>
<outputID>10</outputID>
<state>AOF</state>
<deviceID>3_8</deviceID>
</outlet>
<outlet>
<name>Feed</name>
<outputID>11</outputID>
<state>OFF</state>
<deviceID>Cntl:A1</deviceID>
</outlet>
<outlet>
<name>Maintain</name>
<outputID>12</outputID>
<state>OFF</state>
<deviceID>Cntl:A2</deviceID>
</outlet>
<outlet>
<name>z----</name>
<outputID>13</outputID>
<state>OFF</state>
<deviceID>Cntl:A3</deviceID>
</outlet>
<outlet>
<name>z----------</name>
<outputID>14</outputID>
<state>OFF</state>
<deviceID>Cntl:A4</deviceID>
</outlet>
</outlets>
</status>