
ticketE
Novice
Apr 20, 2013, 3:29 PM
Post #1 of 2
(1093 views)
|
Hi, I have to do a script that make a parse of an xml file. Particulary this script have to save every word conteined in block "category" or "content:encoding" for create a page of feed. Obviously without consider CDATA block. I searched for a long time how to use the XML::Parse but I didn't understand. How could I access to this words? I have to use the SAX library. Please help me
#!/usr/bin/perl -w use strict; use warnings; use utf8; use XML::Parser; use LWP::Simple; my $ruta; $ruta = "http://www.elpais.com/rss/feed.html"; my $re = get($ruta); my $nuevofichero; $nuevofichero='file.xml'; open(NEWFILE, ">>$nuevofichero") || die("impossible to open file : $nuevofichero"); print NEWFILE $re; my $p; $p = new XML::Parser(Style=>'Subs', Pkg=>'Este'); $p->parse($re); exit; package Este; my $message; sub category{ my ($pkg,$element,%attr) = @_; #what does this line? I only saw that element or message contains "category" $message = \%attr; print $element; } sub _category{ #for tag </category> }
|