开发者

What is the correct Xpath query to access an element in Perl's XML::LibXML?

I'm trying to access an element called raw data, inside some <rawData>data is here</rawData> tags. However this XPath query with Perl's XML::LibXML is not working:

foreach my $m ($xc->findnodes(q<//ns:wave[@waveID='1']/ns:well/oneDataSet/rawData>)) {
    print $m->textContent, "\n";
}

but a similar query to get an attribute @wellName is worki开发者_StackOverflow中文版ng fine:

foreach my $n ($xc->findnodes(q<//ns:wave[@waveID='1']/ns:well/@wellName>)) {
    print $n->textContent, "\n";
}

What is wrong with my syntax above for accessing the element?


Without seeing your XML, I couldn't be sure but //ns:wave[@waveID='1']/ns:well/oneDataSet/rawData would make me wonder what namespace oneDataSet and rawData are supposed to be in. Do you need to prefix them?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜