News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Mangling XML as Text with PHP DOM
July 24, 2008 @ 09:35:16

In trying to convert over several HTML pages to the DITA XML format, James Edwards came up against a problem involving recursion:

But a problem I came across several times was the sheer complexity of recursive element conversion '" <code> becomes <jsvalue> (or one of a dozen similar elements), <a> becomes <xref> ' and that's all simple enough; but each of these elements might contain the other, or further child elements like <em>, and as we walk through the DOM so the incidence of potential recursion increases, until it gets to the point where my brain explodes.

His solution involves working with both regular expressions and document fragments. He loads the node he wants to work with, its parsed to prepare it and is passed off to do the "text-based mangling" to update it. The result is them pushed back into an XML object (fragment) and this is pushed back into the main document with a replaceChild call.

0 comments voice your opinion now!
dom xml convert dita replacechild fragment node tutorial


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: OSCON '07 Wrapup

IBuildings techPortal: Understanding APC

Alex Bilbie's Blog: MongoDB + CodeIgniter 101 (Part 1)

IBM developerWorks: Use Ajax with PHP and DB2 9 - Xajax

Ralph Schindler's Blog: Compiling Gearman (or anything) for Zend Server CE on Snow Leopard


Community Events





Don't see your event here?
Let us know!


zendserver opinion release conference symfony framework library introduction bugfix series laravel tips podcast deployment list community language interview threedevsandamaybe api

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework