[CLUE-Tech] PHP/XML and CDATA Woes: The Answer
Matt Gushee
mgushee at havenrock.com
Tue Feb 10 21:52:35 MST 2004
On Fri, Feb 06, 2004 at 03:03:31PM -0700, Jed S. Baer wrote:
> I have discovered the answer to pulling "<![CDATA[ ... ]]>" sections out
> of XML using the PHP Expat parser. I guess it was so obvious that it
> didn't bear any mention in any of the docs.
Well, I was going to try to help, but I guess all's well that ends well.
> I also note that writing a specific parser this way impresses me as being
> less than robust, and likely points to using XSLT as a better solution for
> XML transformations. I suppose it depends upon what you're planning on
> doing with the data, but for changing the display/storage format, I
> suspect XSLT wins 99.9% of the time.
Well, that approach would certainly free you from worrying about the
low-level stuff (e.g. handling end tags). Of course (as I'm sure you
know), writing good XSLT code is a non-trivial task*, and performance
could suck depending on what processor you use. If you want to use some
XSLT, I'd suggest looking at libxslt. It's a GNOME component, but it's
one of the lowest-level ones, so it doesn't depend on much else. It is
mostly standards-compliant and blazingly fast (at least, compared to
every other XSLT processor I've seen); there seems to be a PHP wrapper
for it:
http://nona.net/software/phplibxslt/
Matt
* But I can help if need be.
--
Matt Gushee When a nation follows the Way,
Englewood, Colorado, USA Horses bear manure through
mgushee at havenrock.com its fields;
http://www.havenrock.com/ When a nation ignores the Way,
Horses bear soldiers through
its streets.
--Lao Tzu (Peter Merel, trans.)
More information about the clue-tech
mailing list