in reply to Re^2: Vertical Tab (\x0b) in XML::LibXML 'XML::LibXML'->new( qw/ recover 2 / )->load_xml
in thread Vertical Tab (\x0b) in XML::LibXML

So if you make two passes through libxml you get valid xml? But then you lose the vertical tab ...

If I try using toFile I get  error : xmlEscapeEntities : char out of range

Error seems to be coming from libxml2 itself ... this says sanitize your inputs first so ascii control chars aren't in there :/

I'd report it to XML::LibXML maintainer , for the clues he might provide :)

Replies are listed 'Best First'.
Re^4: Vertical Tab (\x0b) in XML::LibXML
by choroba (Cardinal) on Jul 23, 2014 at 23:04 UTC
    So if you make two passes through libxml you get valid xml?
    No. I make one pass and use something (libxml in this case) to parse the result. If a result was produced, I'd expect the second tool to accept it.

    Sanitizing input seems reasonable, but for such a complex data format, something like

    $text = 'XML::LibXML::Text'->removeInvalidChars($str, $version)
    would be handy.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      No. I make one pass ... removeInvalidChars

      Um,

      sub XML::LibXML::Node::toSanitaryString { my( $node ) = @_; return 'XML::LibXML'->new( qw/ recover 2 / ) ->load_xml(string => $node->toString )->toString; }
      All that is left is to supress the "xmlEscapeEntities : char out of range" warning toSanitaryString generates