tags:

views:

76

answers:

1

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 working 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?

+2  A: 

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?

Nic Gibson
+1 - my thought exactly.
Tomalak