XML DOM - How to strip redundant namespace declaration nodes

From: Date: Thu, 10 Apr 2003 15:05:46 +0000
Subject: XML DOM - How to strip redundant namespace declaration nodes
Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-66@lists.php.net to get a copy of this message
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?

« previous php.xml.dev (#66) next »