Re: simplexml and CDATA



mandric@xxxxxxxxx wrote:

Can someone please enlighten me on how to preserve the <![CDATA[]]>
element when parsing an xml file or string with simplexml. I'm using
libxml 2.6.16 and php 5.1.4.

As far as I've been able to find out this is not possible. However, I
don't think there is a *functional* difference between preserving the
CDATA and what simplexml does. In CDATA sections, you can include e.g.
<i>some</i> HTML elements as-is. They, when parsing, will not result in
separate nodes in the resulting DOM. The XML that $xml->asXML()
generates, escapes the reserved characters (<, >, &) instead. As far as
I can tell this results in functionally the same XML.

Of course, it would be nice if simplexml would remember that a given
element originally held CDATA contents and output it as such. Perhaps
you can file an enhancement request for this.

Gertjan.
--
Gertjan Klein <gklein@xxxxxxxxx>
.



Relevant Pages

  • Re: TAPI 3.0 call attached data
    ... The format of the Call Attached Data is XML. ... XML file with CallAttchedData represents one or multiple data lists ... Root element is CallAttachedData. ... version CDATA #FIXED "1.0" ...
    (microsoft.public.win32.programmer.tapi)
  • Re: Determine if xml is malformed
    ... I'm really looking at how to easily check if the xml file is ... I have an xml file that looks like below. ... <!ATTLIST LIB version CDATA #REQUIRED> ... <!ATTLIST TEST Type CDATA #REQUIRED> ...
    (microsoft.public.dotnet.languages.vb)
  • Re: html in xml
    ... I need to contain some html tag, which is the body of an html email, in a ... I would use XML simple to retrieve the content of the xml file. ... If xml simple uses an xml parser, I would just put it into a CDATA element. ...
    (comp.lang.perl.misc)
  • Re: simplexml and CDATA
    ... element when parsing an xml file or string with simplexml. ... CDATA and what simplexml does. ... In CDATA sections, you can include e.g. ...
    (comp.lang.php)
  • Re: xml in plain text file on heavy load.
    ... even if the XML file is magically and perfectly ... I want to emphasize that IIS would never be caching that XML file on its own ... Application is NOT synchronizing access to your ASP pages. ...
    (microsoft.public.inetserver.iis)