Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: I want to find a group of pattern in a xml file

by kubrat (Scribe)
on Sep 16, 2008 at 14:44 UTC ( #711711=note: print w/replies, xml ) Need Help??

in reply to I want to find a group of pattern in a xml file

Or you could just use XML::Simple. Borrowing from toolic's example:

use strict; use warnings; use XML::Simple; my $xfile = <<EOF; <people> <person><name>Jane Doe</name><age>42</age></person> <person><name>John Doe</name><age>43</age></person> <person><name>Foo Bar</name><age>43</age></person> </people> EOF my $people = XMLin($xfile); foreach (keys %{$people->{person}}) { my $person = $people->{person}->{$_}; next if $person->{age} != 43; print "$_ is $person->{age}\n"; } __END__ John Doe is 43 Foo Bar is 43

Replies are listed 'Best First'.
Re^2: I want to find a group of pattern in a xml file
by cybär (Initiate) on Sep 17, 2008 at 08:11 UTC
    But everytime when I use one of the xml parser modules (twig, simple, etc.) I got errors.
    With the code from superdoc I get following error:
    syntax error at line 1, column 0, byte 0 at C:/Perl/site/lib/XML/ line 187
    The only thing I changed, was instead of the $xfile=text, I wrote $xfile="data.xml";
    Why the hell it's so difficult to use the perl xml modules?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://711711]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-04-19 18:39 GMT
Find Nodes?
    Voting Booth?