[lxml-dev] Encapsulating text in CDATA
Hi Everyone, How can I use CDATA blocks to encapsulate text? I try to add the CDATA identifiers manually, but it doesn't work. Is there a way to do this? I didn' t find anything anything about this on the lxml library documentation. I've just found that the libxml has a function to do this xmlNewCDataBlock, but i didn't find a wrapper for the ElementTree api. Thank you! Matias Gonzalez
Matias wrote:
How can I use CDATA blocks to encapsulate text? I try to add the CDATA identifiers manually, but it doesn't work. Is there a way to do this? I didn' t find anything anything about this on the lxml library documentation. I've just found that the libxml has a function to do this xmlNewCDataBlock, but i didn't find a wrapper for the ElementTree api.
The ElementTree information model is based on the XML infoset, and "CDATA blocks" simply don't exist in the infoset model. They're a file encoding thing, not an information model thing. Or in other words, if you think you need them, you're wrong, or you're not really using XML, and CDATA won't solve your problems. Some related reading: http://www.w3.org/TR/xml-infoset/#omitted http://www.hixie.ch/advocacy/xhtml http://lesscode.org/projects/kid/ticket/99 (read the comments) </F>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matias wrote:
Hi Everyone,
How can I use CDATA blocks to encapsulate text? I try to add the CDATA identifiers manually, but it doesn't work. Is there a way to do this? I didn' t find anything anything about this on the lxml library documentation. I've just found that the libxml has a function to do this xmlNewCDataBlock, but i didn't find a wrapper for the ElementTree api.
Hi Matias, CDATA sections in your input are automatically converted to normal text in the element tree. At the moment, lxml uses some of libxml2's magic to detect XHTML output. In this case, CDATA sections may also be found in lxml output in e.g. <script> elements. You have no control over this however, and the output could just as well have been without CDATA sections but instead with escaped < entities. Regards, Geert -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEVAwUBQ7HRYJrPkVOV4lDgAQI5Uwf/W2Tq/l9A69pOFm5eQVCFQfmn8erXoKE1 ArvfKqPQTAMxtaXsMezMkFT57cx0SDTaEYu1GZ50rG1b/ZwoEwlfjvNi0tgTqzbA /k8HqmOYDrB8A762B5ilcEgSxP5mSH6W4lPflVvgDgBdl4PHgCyDs9S7l2PwW4Ll CMsA6YaDr7kVGlZ9mPAS0FBZ3qQRL/kxK0EcEcw1OApucG0jKBb/a/JzRkNQZPWs tZEcEBztonm4kub6lwDz9AeMd7DKqs50McSadA0ElKtlZat9YHIetjAjvHNVkw9z 3eFdyGe3ug50/rryVCN6rmw0IepdlIyArEtqifDVEorZhL4+1NYBAg== =bXla -----END PGP SIGNATURE-----
participants (3)
-
Fredrik Lundh
-
Geert Jansen
-
Matias