Hue-Bond has asked for the wisdom of the Perl Monks concerning the following question:
Wise monks,
Been a long time without posting here :^). I'm creating an RSS 2.0 feed. The code checks for new items from a forum and turns them into a proper XML file. We're planning to do this once an hour or so. Then I discovered that Google Reader (my RSS client) only polls the feed every three hours. This means that if I don't keep items between runs of the program, Google Reader will only catch the items posted to the forum in the last hour, so to avoid this I designed the following plan:
If you think there's a better way to approach this problem, please stop reading now ;^).
I'm getting a segmentation fault when extracting the title and the date from an item. This code triggers it:
#!/usr/bin/perl ## the version of XML::LibXML installed in the system is 1.63, so I tr +ied installing 1.65 here: BEGIN { unshift @INC, '/tmp/pm/lib/perl/5.8.8'; } use warnings; use strict; use XML::LibXML; print "Version: ", $XML::LibXML::VERSION, "\n"; my $parser = XML::LibXML->new; my $item = $parser->parse_balanced_chunk (<<'EOT'); <item> <title>Insert title here</title> <link>http://foo/bar.html</link> <description>Insert description here</description> <guid isPermaLink="false">foobar@19700101:000000+0000</guid> </item> EOT my $title = $item->findvalue ('//title'); print "Still alive!\n"; my $date = $item->findvalue ('//guid'); print "Still alive!\n"; print "got title ($title) and date ($date)\n";
$ ./foo.pl Version: 1.65 Still alive! Segmentation fault (core dumped)
I discovered this in a production system with libxml2 version 2.6.27, then I investigated it in my laptop with 2.6.30. Same result in both machines.
--
David Serrano
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting elements from an XML chunk leads to crash
by erroneousBollock (Curate) on Oct 22, 2007 at 00:47 UTC | |
|
Re: Extracting elements from an XML chunk leads to crash
by Cody Pendant (Prior) on Oct 22, 2007 at 04:09 UTC | |
by Hue-Bond (Priest) on Oct 24, 2007 at 08:36 UTC | |
|
Re: Extracting elements from an XML chunk leads to crash
by Krambambuli (Curate) on Oct 22, 2007 at 10:11 UTC |