Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

CDATA sections originate from a related SGML concept and are used for verbatim text (like code).

They are simply a way to stop any special entity-like processing and are certainly *not* meant for binary data. They are many schemes for binary XML.

If the document is valid UTF-8, then base64-enc of values is useful and does not need escaping as quotes are not part of the image set. Obviously you could also use directly the encoding data in a CDATA section but it seems less useful than:

<data local_enc="base64"> <value>c3RlcGhhbgo=</value> </data>
The whole arsenal of MIME/PEM conversions can be used. But be careful, there is one pitfall: the scheme *breaks* if the xml document uses an (at least 2 bytes) encoding like UTF-16 as a base64 sequence of bytes is not valid UTF-16. The solution is to use an extra conversion like  iconv -f ISO-88859-1 -t UTF-16 and its inverse.

Finally one way to encode  ]]> would be to close the CDATA section after outputting ]] and then open another one starting with  >

cheers --stephan

In reply to Re: binary data in XML by sgt
in thread binary data in XML by sailortailorson

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-06-06 12:22 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.