The objectify_text call just seems to invert the problem. Though I can be rather obtuse and may not see the right way to use it.

I might be able to fit XML::LibXML into the full script and replace HTML::TreeBuilder::XPath. Here is my sketch,

#!/usr/bin/perl use XML::LibXML; use strict; use warnings; my $tree = XML::LibXML->load_xml(IO => \*DATA); my $dtd = XML::LibXML::XPathContext->new( $tree->documentElement() ); $dtd->registerNs( 'u' => 'http://www.w3.org/1999/xhtml' ); for my $body ($dtd->findnodes('//u:body')) { # print $body->toString; for my $n ($body->childNodes()) { print $n->toString; } } print "\n"; print "OK\n"; exit(0); __DATA__ <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for HTML5 for Linux version 5.6.0" /> <title></title> </head> <body> <p>foo</p> <p>bar</p> trololo </body> </html>

In reply to Re^2: Seemingly Valid HTML which crashes HTML::TreeBuilder::XPath by mldvx4
in thread Seemingly Valid HTML which crashes HTML::TreeBuilder::XPath by mldvx4

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.