Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: binary data in XML (CDATA, ha!)

by tye (Sage)
on Feb 28, 2008 at 18:40 UTC ( #670975=note: print w/replies, xml ) Need Help??


in reply to Re^2: binary data in XML
in thread binary data in XML

CDATA doesn't, in fact, make the least bit of difference as to what characters you can include in the data. You can't put (unencoded) binary data into XML using CDATA. The only difference between non-CDATA and CDATA is that one requires you to encode some single-character items while the other requires you to encode one 3-character sequence. This makes CDATA quite silly, IMHO.

And, no, you can't even use  to get "binary" characters into XML.

- tye        

Replies are listed 'Best First'.
Re^4: binary data in XML (CDATA, ha!)
by Fletch (Bishop) on Feb 28, 2008 at 19:08 UTC

    Perhaps I was a little unclear, so for the benefit of the slow, I was offering two alternatives:

    • Use CDATA if you've got character data that otherwise would be interpreted as markup and don't mind the onerous task of encoding the commonly appearing sequence "]]>" instead of encoding every other offending single character individually (say you had Perl code which was otherwise free of verboten characters but chock full of > and < etc)
    • Use an out-of-band encoding such as base64 which is handled at the application layer rather than by the XML parser itself for what would otherwise be invalid character data (a sequence of octets which would be outside XML's allowed range when interpreted)

    Given that there was no example of what exactly the offending "binary data" was I thought it best to offer both options: the simple for more vanilla ASCII-y data and encoding for arbitrary octet streams.

    Update: Further clarified what types of data suggest which alternative.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2023-10-04 16:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?