protected function buildDomDocumentFromXml($xml)
    {
        // see the following URL for this trick:
        // http://stackoverflow.com/questions/15223224/how-to-remove-all-namespaces-from-xml-in-php-tags-and-attributes

        $sxe     = new \SimpleXMLElement($xml);
        $dom_sxe = dom_import_simplexml($sxe);

        $dom     = new DOMDocument('1.0');
        $dom_sxe = $dom->importNode($dom_sxe, true);
        $dom->appendChild($dom_sxe);

        /** @var DOMElement $element */
        $element = $dom->childNodes->item(0);


        foreach ($sxe->getDocNamespaces(true) as $name => $uri) {

            $element->removeAttributeNS($uri, $name);
        }

        return $dom;
    }
protected function buildDomDocumentFromXml($xml)
    {
        // see the following URL for this trick:
        // http://stackoverflow.com/questions/15223224/how-to-remove-all-namespaces-from-xml-in-php-tags-and-attributes

        $sxe     = new \SimpleXMLElement($xml);
        $dom_sxe = dom_import_simplexml($sxe);

        $dom     = new DOMDocument('1.0');
        $dom_sxe = $dom->importNode($dom_sxe, true);
        $dom->appendChild($dom_sxe);

        /** @var DOMElement $element */
        $element = $dom->childNodes->item(0);


        foreach ($sxe->getDocNamespaces(true) as $name => $uri) {

            $element->removeAttributeNS($uri, $name);
        }

        return $dom;
    }
protected function buildDomDocumentFromXml ( $ xml ) { // see the following URL for this trick: // http://stackoverflow.com/questions/15223224/how-to-remove-all-namespaces-from-xml-in-php-tags-and-attributes $ sxe = new \ SimpleXMLElement ( $ xml ) ; $ dom_sxe = dom_import_simplexml ( $ sxe ) ; $ dom = new DOMDocument ( '1.0' ) ; $ dom_sxe = $ dom -> importNode ( $ dom_sxe , true ) ; $ dom -> appendChild ( $ dom_sxe ) ; /** @var DOMElement $element */ $ element = $ dom -> childNodes -> item ( 0 ) ; foreach ( $ sxe -> getDocNamespaces ( true ) as $ name => $ uri ) { $ element -> removeAttributeNS ( $ uri , $ name ) ; } return $ dom ; }
Strip namespaces from XML string

@param  string $xml
@return string
Strip namespaces from XML string