XML DOM - How to strip redundant namespace declaration nodes
[email protected] ("Markus Pfefferle")
| Newsgroups | php.xml.dev |
|---|---|
| Organization | Intelligent Media Systems AG |
| Message-ID | <[email protected]> |
Hi, perhaps you can help me.
I'm assembling a large XML document out of several smaller ones, using
elements with namespaces. Since these smaller ones have to be valid too,
namespace declarations are used in their document elements. When imported
into a large document, these namespace declaration nodes however remain,
inspite of the same namespaces being declared in an higher element already.
Although this behavior is "natural" for clone_node() and append_child(),
after the assembly of the larger document, I'd like to get rid of all the
redundant declarations in anything but the top document element.
PHP's DOM implementation however does not give me any method of accessing
these declaration-nodes - or at least none documented I can find.
In this example:
<?xml version="1.0"?>
<ims:envelope xmlns:ims="http://www.domain.com/ns">
<ims:reply code="200" execution_time="0.006">OK</ims:reply>
<ims:session xmlns:ims="http://www.domain.com/ns" created="1049986974"
identifier="ndLxzE7SKK7vaubeYfjV"/>
</ims:envelope>
How can I 'clean' the ims:session element of its redundant namespace
declaration? Any ideas?