我有一个 XML 文件,其中一部分如下所示:
<wave waveID="1">
<well wellID="1" wellName="A1">
<oneDataSet>
<rawData>0.1123975676</rawData>
</oneDataSet>
</well>
... more wellID's and rawData continues here...
我正在尝试使用 Perl 的 libXML 解析文件并使用以下命令输出 wellName 和 rawData:
use XML::LibXML;
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file('/Users/johncumbers/Temp/1_12-18-09-111823.orig.xml');
my $xc = XML::LibXML::XPathContext->new( $doc->documentElement() );
$xc->registerNs('ns', 'http://moleculardevices.com/microplateML');
my @n = $xc->findnodes('//ns:wave[@waveID="1"]'); #xc is xpathContent
# should find a tree from the node representing everything beneath the waveID 1
foreach $nod (@n) {
my @c = $nod->findnodes('//rawData'); #element inside the tree.
print @c;
}
它现在没有打印出任何东西,我认为我的 Xpath 语句有问题。请你能帮我修复它,或者你能告诉我如何解决xpath语句吗?谢谢。