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" +/>
In reply to Parsing XML that contains HTML by ruhk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |