Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: XML::TokeParser, how to use it??

by sk (Curate)
on Jul 04, 2005 at 21:47 UTC ( [id://472311]=note: print w/replies, xml ) Need Help??


in reply to XML::TokeParser, how to use it??

Do you just want to extract the links which are stored inside the permalink tags? If it is as simple as that I would just use a regex to do it -

#!/usr/bin/perl -w while(<DATA>) { if (/permalink/) { s|<permalink>(.*)</permalink>|$1|i; print; } } __DATA__ <permalink> Link A </permalink> <tempNode> value1 </tempNode> SomeText <permalink> Link B </permalink> <tempNode2> value2 </tempNode2> <permalink> Link C </permalink>
Output

Link A Link B Link C

If you are looking to parse the XML file cleanly for other purposes then you can check out XML::DOM. I don't have XML::TokeParser on my machine to check out code but XML::DOM should be easy to use. http://search.cpan.org/~tjmather/XML-DOM-1.43/lib/XML/DOM.pm

cheers

SK

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://472311]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found