Created
October 16, 2018 12:41
-
-
Save kobus1998/0f07f6d313a1b34963db124682cbcb1b to your computer and use it in GitHub Desktop.
Strip XML namespaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// namespaces can be a pain in the ass, well NO LONGER! | |
function stripNamespaces($xml) | |
{ | |
return preg_replace([ | |
"/(\<(\w*|\-)*\:)/", // start node namespaces | |
"/(\<(\/{0,1})(\w*|\-)*\:)/", // end node namespaces | |
"/(\s\w*\:)/" // attribute namespaces | |
], [ | |
"<", | |
"</", | |
" " | |
], $xml); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment