Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by choroba (Cardinal)
on Jul 23, 2014 at 22:15 UTC ( [id://1094856]=note: print w/replies, xml ) Need Help??


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

That's not my problem. I need to generate well-formed XML that can be loaded by other tools, too. Some of them don't use XML::LibXML nor Perl.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^3: Vertical Tab (\x0b) in XML::LibXML
by Anonymous Monk on Jul 23, 2014 at 22:50 UTC

    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 :)

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1094856]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-29 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found