Binford has asked for the wisdom of the Perl Monks concerning the following question:
Why doesn't this work to output the STATUS node per line?<APPLIANCE_LIST_OUTPUT> <RESPONSE> <DATETIME>2014-06-27T13:38:55Z</DATETIME> <APPLIANCE_LIST> <APPLIANCE> <ID>76297</ID> <NAME>st0153</NAME> <SOFTWARE_VERSION></SOFTWARE_VERSION> <RUNNING_SCAN_COUNT>0</RUNNING_SCAN_COUNT> <STATUS>Online</STATUS> </APPLIANCE> <APPLIANCE> <ID>53489</ID> <NAME>THD-Mexico</NAME> <SOFTWARE_VERSION>2.6</SOFTWARE_VERSION> <RUNNING_SCAN_COUNT>0</RUNNING_SCAN_COUNT> <STATUS>Online</STATUS> </APPLIANCE> <APPLIANCE> <ID>76079</ID> <NAME>QAPLRScanner</NAME> <SOFTWARE_VERSION></SOFTWARE_VERSION> <RUNNING_SCAN_COUNT>0</RUNNING_SCAN_COUNT> <STATUS>Online</STATUS> </APPLIANCE> </APPLIANCE_LIST> </RESPONSE> </APPLIANCE_LIST_OUTPUT>
Ive' tried various ways to do this, but no matter what irt doesn't seem to enter the "for" loop. BUt if I change the Xpath, it complains, so it seems to READ the XML and have it parsed correctly, but won't examine it? Stumped, thanks in advance...use XML::LibXML qw(); my $xml = XML::LibXML->load_xml(location => 'output.xml'); for ($xml->findnodes('//appliance_list_output[@status]')) { print $_->getAttribute('status') . "\n"; #print $_->getElementsbyTagName('status') . "\n"; print $_ . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LibXML question
by AppleFritter (Vicar) on Jun 27, 2014 at 19:59 UTC | |
by choroba (Cardinal) on Jun 27, 2014 at 23:10 UTC |