Two things.
First of all, XML is case-sensitive. appliance_list_output is not the same as APPLIANCE_LIST_OUTPUT, and the same goes for status and STATUS.
Second (after reading up on XPath), you're not getting results because you're only querying for the status attributes of APPLIANCE_LIST_OUTPUT nodes, as opposed to STATUS nodes descended from them. Try the following:
#!/usr/bin/perl use feature qw/say/; use XML::LibXML qw(); my $xml = XML::LibXML->load_xml(location => 'output.xml'); for ($xml->findnodes('//APPLIANCE_LIST_OUTPUT/descendant::STATUS/text( +)')) { say; }
Here's the output:
Online Online Online
I've also used text() to select the text content of the status nodes, BTW. Leaving that out, you'd get "<STATUS>Online</STATUS>" for each node, rather than just "Online".
Does this do what you want?
BTW, here's a useful XPath tutorial site.
In reply to Re: LibXML question
by AppleFritter
in thread LibXML question
by Binford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |