我想用perl解析xml文件,我想检索Audit标签的值,但是没有产生输出。以下代码不打印输出
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
my $xml = <<'__EOI__';
<scanJob>
<hosts>
<host>
<audit>
<rthID>31406</rthID>
<cve>N/A</cve>
<cce>N/A</cce>
<iav>N/A</iav>
<name>OpenSSH Memory Corruption Vulnerability - (20131108) - Banner</name>
<description>OpenSSH 6.4 </description>
<pciReason>Default</pciReason>
<pciPassFail>Pass</pciPassFail>
<cvssScore>N/A</cvssScore>
<fixInformation>Upgrade OpenSSH 6.4 or later.</fixInformation>
<exploit>No</exploit>
<context>TCP:22</context>
</audit>
</host>
</hosts>
</scanJob>
__EOI__
my $xs = new XML::Simple;
my $data = $xs->XMLin(\$xml);
for my $scanJob (@{$data->{scanJob} }) {
for my $hosts (@{$scanJob->hosts }) {
for my $host (@{$hosts->host }) {
for my $audit (@{$host->audit }) {
my $rthID = $audit->{rthID};
print $rthID;
}
}
}
}
你可以发布你正在试图解析XML? – mirod
你不能编辑您的帖子?很难从评论中读取 – mirod