この XML<current></current>
の最初の 2 つの値 (37%
と)を解析する方法を見つけようとしています。61.8F
それらは同じフィールド名を持ち、すべて「センサー」の下にあるように見えるので、私はそれを理解できません...助けていただければ幸いです...
Perl のコード:
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
use LWP::Simple;
$url = 'http://localhostmachine/output/XML/output.xml';
# create object
my $xml = XML::Simple->new();
# read XML file
$data = $xml->XMLin(get($url));
# print output
print Dumper($data);
私が読んでいるXMLファイルの出力:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="wpman.xsl"?>
<watchport>
<title>
<TxtTitle>Location#1</TxtTitle>
</title>
<sensor>
<type>Combo Sensor (Humidity)</type>
<name>ComboSensor000</name>
<status>OK</status>
<current>37%</current>
<high>42 (10/19/2009 @ 04:05PM)</high>
<low>28 (10/17/2009 @ 11:26AM)</low>
</sensor>
<sensor>
<type>Combo Sensor (Temperature)</type>
<name>ComboSensor000</name>
<status>OK</status>
<current>61.6F</current>
<high>65.8 (10/17/2009 @ 11:26AM)</high>
<low>60.1 (10/19/2009 @ 04:00PM)</low>
</sensor>
<sensor>
<type> </type>
<name> </name>
<status> </status>
<current> </current>
</sensor>
<sensor>
<type>Updated: 10/19/2009 @ 05:47 PM</type>
<name>(Updated every 2 minutes)</name>
<status> </status>
<current> </current>
</sensor>
</watchport>
本当にありがとう!