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


In reply to Extracting elements from an XML chunk leads to crash by Hue-Bond

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.