in reply to Extracting elements from an XML chunk leads to crash

Your sample doesn't segfault for me (WinXP, Perl 5.8.8, AS-817), but it also doesn't produce any useful value from the second XPath expression either... no matter what the expression is or the document contains.

Don't you need a call to XML::LibXML::XPathContext->new there somewhere, passing the fragment node created by parse_balanced_chunk? Or is there some cute shorthand for the xpath context you can use directly from the doc/frag node?

-David