Using Dom Objects in PHP, the default namespace is redeclared in some nodes.

Posted by TomcatExodus on Stack Overflow See other posts from Stack Overflow or by TomcatExodus
Published on 2011-01-07T18:48:29Z Indexed on 2011/01/07 18:53 UTC
Read the original article Hit count: 201

Filed under:
|
|
|
|

I'm working on a template engine, having migrated from regex driven to DOM driven. It appears though, that whenever I create a DomDocumentFragment to encapsulate some portion of a document temporarily, the namespace attribute is added to each node in the fragment. Since my default namespace for a given document will 99% of the time be XHTML, it's adding the XHTML namespace declaration.

Being the default namespace, this seems fruitless, and ultimately nodes in any other namespace will be stripped out at render time anyways.

Aside from iteratively removing namespace attributes, is there some way I can prevent this from occurring to begin with? Its quite problematic, as this will likely increase render time filesize considerably, as large portions of a given document may be stored in a fragment.

I've tried $doc->normalizeDocument(), but as I assumed, it did nothing.

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml