src/XmlUtil.php
public static function innerXML(\DOMNode $node, $xmlstring)
    {
        $xmlstring = str_replace("<br>", "<br/>", $xmlstring);
        $len = strlen($xmlstring);
        $endText = "";
        $close = strrpos($xmlstring, '>');
        if ($close !== false && $close < $len - 1) {
            $endText = substr($xmlstring, $close + 1);
            $xmlstring = substr($xmlstring, 0, $close + 1);
        }
        $open = strpos($xmlstring, '<');
        if ($open === false) {
            $node->nodeValue .= $xmlstring;
        } else {
            if ($open > 0) {
                $text = substr($xmlstring, 0, $open);
                $xmlstring = substr($xmlstring, $open);
                $node->nodeValue .= $text;
            }
            $dom = XmlUtil::getOwnerDocument($node);
            $xmlstring = "<rootxml>$xmlstring</rootxml>";
            $sxe = @simplexml_load_string($xmlstring);
            if ($sxe === false) {
                throw new XmlUtilException("Cannot load XML string.", 252);
            }
            $domSimpleXml = dom_import_simplexml($sxe);
            if (!$domSimpleXml) {
                throw new XmlUtilException("XML Parsing error.", 253);
            }
            $domSimpleXml = $dom->importNode($domSimpleXml, true);
            $childs = $domSimpleXml->childNodes->length;
            for ($i = 0; $i < $childs; $i++) {
                $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true));
            }
        }
        if (!empty($endText) && $endText != "") {
            $textNode = $dom->createTextNode($endText);
            $node->appendChild($textNode);
        }
        return $node->firstChild;
    }
public static function innerXML(\DOMNode $node, $xmlstring)
    {
        $xmlstring = str_replace("<br>", "<br/>", $xmlstring);
        $len = strlen($xmlstring);
        $endText = "";
        $close = strrpos($xmlstring, '>');
        if ($close !== false && $close < $len - 1) {
            $endText = substr($xmlstring, $close + 1);
            $xmlstring = substr($xmlstring, 0, $close + 1);
        }
        $open = strpos($xmlstring, '<');
        if ($open === false) {
            $node->nodeValue .= $xmlstring;
        } else {
            if ($open > 0) {
                $text = substr($xmlstring, 0, $open);
                $xmlstring = substr($xmlstring, $open);
                $node->nodeValue .= $text;
            }
            $dom = XmlUtil::getOwnerDocument($node);
            $xmlstring = "<rootxml>$xmlstring</rootxml>";
            $sxe = @simplexml_load_string($xmlstring);
            if ($sxe === false) {
                throw new XmlUtilException("Cannot load XML string.", 252);
            }
            $domSimpleXml = dom_import_simplexml($sxe);
            if (!$domSimpleXml) {
                throw new XmlUtilException("XML Parsing error.", 253);
            }
            $domSimpleXml = $dom->importNode($domSimpleXml, true);
            $childs = $domSimpleXml->childNodes->length;
            for ($i = 0; $i < $childs; $i++) {
                $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true));
            }
        }
        if (!empty($endText) && $endText != "") {
            $textNode = $dom->createTextNode($endText);
            $node->appendChild($textNode);
        }
        return $node->firstChild;
    }
public static function innerXML ( \ DOMNode $ node , $ xmlstring ) { $ xmlstring = str_replace ( "<br>" , "<br/>" , $ xmlstring ) ; $ len = strlen ( $ xmlstring ) ; $ endText = "" ; $ close = strrpos ( $ xmlstring , '>' ) ; if ( $ close !== false && $ close < $ len - 1 ) { $ endText = substr ( $ xmlstring , $ close + 1 ) ; $ xmlstring = substr ( $ xmlstring , 0 , $ close + 1 ) ; } $ open = strpos ( $ xmlstring , '<' ) ; if ( $ open === false ) { $ node -> nodeValue .= $ xmlstring ; } else { if ( $ open > 0 ) { $ text = substr ( $ xmlstring , 0 , $ open ) ; $ xmlstring = substr ( $ xmlstring , $ open ) ; $ node -> nodeValue .= $ text ; } $ dom = XmlUtil :: getOwnerDocument ( $ node ) ; $ xmlstring = "<rootxml>$xmlstring</rootxml>" ; $ sxe = @ simplexml_load_string ( $ xmlstring ) ; if ( $ sxe === false ) { throw new XmlUtilException ( "Cannot load XML string." , 252 ) ; } $ domSimpleXml = dom_import_simplexml ( $ sxe ) ; if ( ! $ domSimpleXml ) { throw new XmlUtilException ( "XML Parsing error." , 253 ) ; } $ domSimpleXml = $ dom -> importNode ( $ domSimpleXml , true ) ; $ childs = $ domSimpleXml -> childNodes -> length ; for ( $ i = 0 ; $ i < $ childs ; $ i ++ ) { $ node -> appendChild ( $ domSimpleXml -> childNodes -> item ( $ i ) -> cloneNode ( true ) ) ; } } if ( ! empty ( $ endText ) && $ endText != "" ) { $ textNode = $ dom -> createTextNode ( $ endText ) ; $ node -> appendChild ( $ textNode ) ; } return $ node -> firstChild ; }
Concat a xml string in the node

@param \DOMNode $node
@param string $xmlstring
@return \DOMNode
@throws \ByJG\Util\Exception\XmlUtilException
Concat a xml string in the node