#!/usr/bin/perl use warnings; use strict; my $a = do {local $/; <DATA>}; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(xml => $a); foreach my $cid ($xp->findnodes('/PartyA/com.Info')) { my $code = $cid->find('Rule/@action')->string_value; print "\n$code\n"; } __DATA__ <?xml version="1.0" encoding="UTF-8"?> <PartyA> <Real/> <com.Info> <Action>A</Action> <Rule action="Required">TQA</Rule> <Item> <Other> <Type>Key</Type> </Other> <Other> <Type>com.csc_ClientKey</Type> <OtherId>700</OtherId> </Other> <Other> <Type>Sum</Type> </Other> </Item> </com.Info> <Real/> <com.Info> <Action>A</Action> <Rule>YWX</Rule> <Item> <Other> <Type>Key</Type> </Other> <Other> <Type>com.csc_ClientKey</Type> <OtherId>500</OtherId> </Other> <Other> <Type>Sum</Type> </Other> </Item> </com.Info> </PartyA>
In reply to Finding Data based on attribute help! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |