perl - How can I extract values from the XML::Simple's data structure? -


I'm trying to explain that & lt; Current & gt; & Lt; / Current & gt; I do not understand the value in this XML first 2 ( 37% and 61.8F ) because it seems that they have the same field names And they are all under 'sensors' ... any help would be appreciated ...

Code in Perl:

  #! / Usr / bin / perl XML :: Simple; Use data: Dumper; LWP :: Simple; $ Url = 'http: //localhostmachine/output/XML/output.xml'; # Create my $ xml = XML :: Simple-> new () item; #xml file $ data = $ xml- & gt; XMLin (get ($ url)); #print output print dumper ($ data);  

The output of the XML file I am reading:

   42 (10/19/2009 @ 04:05 pm) & lt; / High & gt; & Lt; Less & gt; 28 (10/17/2009 @ 11:26 AM) & lt; / Low> & Lt; / Sensor & gt; & Lt; Sensor & gt; & Lt; Type & gt; Combo sensor (temperature) & lt; / Type & gt; & Lt; Name & gt; ComboSensor000 & lt; / Name & gt; & Lt; Status & gt; OK & lt; / Status & gt; & Lt; Current & gt; 61.6F & lt; / Current & gt; & Lt; High> 65.8 (10/17/2009 @ 11:26 AM) & lt; / High & gt; & Lt; Less & gt; 60.1 (10/19/2009 @ 04:00 pm) & lt; / Low> & Lt; / Sensor & gt; & Lt; Sensor & gt; & Lt; Type & gt; & Lt; / Type & gt; & Lt; Name & gt; & Lt; / Name & gt; & Lt; Status & gt; & Lt; / Status & gt; & Lt; Current & gt; & Lt; / Current & gt; & Lt; / Sensor & gt; & Lt; Sensor & gt; & Lt; Type & gt; Updated: 10/19/2009 @ 05:47 pm & lt; / Type & gt; & Lt; Name & gt; (Updated every 2 minutes) & lt; / Name & gt; & Lt; Status & gt; & Lt; / Status & gt; & Lt; Current & gt; & Lt; / Current & gt; & Lt; / Sensor & gt; & Lt; / Watchport & gt;  

Thanks a lot!

I think this is what you want.

  Print $ data- & gt; {Censor} [0] {current}; Print $ data- & gt; {Censor} [1] {current};  

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -