Re: Getting XML Nodes based on attributes value
by Robin Berjon other posts by this author
Sep 7 2005 5:08AM messages near this date
view in the new Beta List Site
Re: Getting XML Nodes based on attributes value
|
Re: Getting XML Nodes based on attributes value
& XSLT Hi,
Joseph C. Bautista wrote:
> I was wondering if there's a module that i can used to get only the
> nodes in an XML file based on the attributes value?
The simplest thing to use would be either XML::LibXML or XML::XPath. In
both you can use XPath to retrieve your nodes, which is a very powerful
way of processing XML.
> Example XML is:
>
> <Things>
> <Object Class="Pens" Location="Room">
> <p name="length">4<\p>
> <p name="thickness">.5</p>
> <p name="color">yellow</p>
> </Object>
> </Things>
>
> If I want to retrieve only the objects with class "Pens"
You would do:
my @nodes = $document-> findnodes("//Object[@Class='Pens']");
or some variant on that.
--
Robin Berjon
Senior Research Scientist
Expway, http://expway.com/
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Joseph C. Bautista
Tod Harter
Mark - BLS CTR Thomas
Andrew Strader
Joseph C. Bautista
Joseph C. Bautista
Petr Pajas
Robin Berjon
Merijn van den Kroonenberg
|