ruhk has asked for the wisdom of the Perl Monks concerning the following question:
This works great, except for the fact that the links in an atom feed are stored like this:my $content = get("foo/bar.xml"); die "Couldn't get it!" unless defined $content; my $t= XML::Twig->new( # the twig will include just the root and selected titles twig_roots => { 'summary/div' => \&grabDiv, 'title' => \&grabTitle, 'entry/link' => \&grabLinks + } ); $t->parse($content); sub grabDiv { my( $t, $elt)= @_; push ( @divs , $elt->text); # print the text (including sub-e +lement texts) $t->purge; # frees the memory } sub grabTitle { my( $t, $elt)= @_; push( @headlines, $elt->text); # print the text (including su +b-element texts) $t->purge; # frees the memory } sub grabLinks { my( $t, $elt)= @_; my $thingey = $elt->{'href'}; push( @links, $elt->text); # print the text (including sub-el +ement texts) $t->purge; # frees the memory }
Ive sat here furiosly staring at the screen for some time now, but I cant seem to find the answer. Is there a way XML::Twig can do this or will I have to come up with some kind of dirty regex?<link href="foo/bar.html" rel="alternate" title="Foo" type="text/html" +/>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing XML that contains HTML
by iburrell (Chaplain) on Jul 21, 2004 at 17:13 UTC | |
by ruhk (Scribe) on Jul 21, 2004 at 17:23 UTC | |
|
Re: Parsing XML that contains HTML
by The Mad Hatter (Priest) on Jul 21, 2004 at 17:21 UTC | |
by ruhk (Scribe) on Jul 21, 2004 at 18:08 UTC |