in reply to parsing xml file using LIBXML
Various points to make...
- as mirod says, that's an ugly piece of XML. But that's not the problem we're here to solve today...
- getElementsByTagName works only on a Document object, not on any element: it finds all the elements with the given name anywhere in the document. I don't think that's what you need.
- to do the match, you could use getAttribute() to get the value of the use attribute, and then use a regexp or something similar to test if it contains the value passed from the command line. Like:
where the \Q...\E is to avoid strange characters from being interpreted by the regexp engine.$attrValue =~ /\Q$param\E/ - learn XPath. Really do. That whole program can be reduced to a single XPath query. And it would be easier to read.
-- dakkar - Mobilis in mobile
Most of my code is tested...
|
---|
In Section
Seekers of Perl Wisdom