Exemple #1
0
 /**
  *
  * @param \DOMNode $node
  * @param string $name
  * @param string $uri
  * @return \DOMNode
  * @throws XmlUtilException
  */
 protected static function createChildNode(\DOMNode $node, $name, $uri = "")
 {
     if ($uri == "") {
         XmlUtil::checkIfPrefixWasDefined($node, $name);
     }
     $owner = self::getOwnerDocument($node);
     if ($uri == "") {
         $newnode = $owner->createElement(preg_replace('/[^\\w:]/', '_', $name));
     } else {
         $newnode = $owner->createElementNS($uri, $name);
         if ($owner == $node) {
             $tok = strtok($name, ":");
             if ($tok != $name) {
                 XmlUtil::$XMLNSPrefix[spl_object_hash($owner)][$tok] = $uri;
             }
         }
     }
     if ($newnode === false) {
         throw new XmlUtilException("Failed to create \\DOMElement.", 258);
     }
     return $newnode;
 }