我不知道如何使用 Perl 中的 XML::Simple 模块检查节点是否包含值...这是我的代码:
my $parser = XML::Simple->new;
my $url = 'http://some/xml.aspx';
my $content = get $url or die "Unable to get $url\n";
my $data = $parser->XMLin($content);
print "Content-Type: text/html; charset=utf-8\n\n";
foreach my $property (@{$data->{propertyList}}) {
if ($property->{'boiler'}) {
print Dumper($property->{'boiler'});
}
}
一些Boiler
节点可以为空,输出如下所示:
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = {};
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = {};
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = {};
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
$VAR1 = {};
$VAR1 = "\x{5e9}\x{5de}\x{5e9}";
第四个$VAR1
是空的,但我如何在代码中检查它?
先感谢您