I have a DOMDocument. I know the URI of the namespace I want to remove, but I don't know the prefix. How do I remove all references to that namespace from my DOMDocument, without transforming it to text and regexping / xmlns:.+?\s*=\s*"$scheme"/ and replacing that with a blank?
A little background: I am using my own namespace to help cordon off proprietary extensions I'm making to XHTML (normally, I'd try to fit things into already valid HTML elements, but there's only so much one can do). A post-processor converts these to valid HTML, at which point they have no meaning anymore and should be removed. But I can't figure out how to!
Xmlns attributes seem to get special treatment from PHP's DOM specification. While getAttribute('xmlns:php') works properly, the xmlns attributes do not show up in the attributes property of an element. This is reasonable, as DOM is early binding and each node should be directly associated with the namespace URI. However, DOM is definitely retaining information on the original prefixes, otherwise it would have dropped the namespace declaration when it realized nothing was referencing it.
Remove xmlns:* attribute based on URI scheme
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
getElementsByTagNameNS('http://namespaec/URI','*') should select all the nodes you're after... but I have no idea how to change / remove the NS 
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US