in reply to Re: How to parse a xml file using XML::DOM??
in thread How to parse a xml file using XML::DOM??

Got your point but for some reason have to use XML::DOM only. Can you help me with that ?

  • Comment on Re^2: How to parse a xml file using XML::DOM??

Replies are listed 'Best First'.
Re^3: How to parse a xml file using XML::DOM??
by Corion (Patriarch) on Sep 22, 2016 at 12:15 UTC

    Looking at the documentation of XML::DOM, it shows the use of ->getElementsByTagName. The simplest approach would then be something like:

    my $signals = $doc->getElementsByTagName('signal'); my @by_id = grep { my $sigid= $_->getAttributeNode('sigid'); if( $sigid ) { $sigid == 3464 } else { 0 # no sigid attribute, no match } } map { $signals->item($_) } 0..$signals->getLength()-1

    I still recommend using an XPath query.