当前位置: 首页>>代码示例>>PHP>>正文


PHP domDocument::createElementNS方法代码示例

本文整理汇总了PHP中domDocument::createElementNS方法的典型用法代码示例。如果您正苦于以下问题:PHP domDocument::createElementNS方法的具体用法?PHP domDocument::createElementNS怎么用?PHP domDocument::createElementNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在domDocument的用法示例。


在下文中一共展示了domDocument::createElementNS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addElement

 /**
  * Adds an child element to the parent
  * @param string The name element
  * @param domNode 
  * @return domNode
  */
 private function addElement($name, $parent = false, $ns = false)
 {
     if ($ns) {
         $el = $this->doc->createElementNS($ns, $name);
     } else {
         $el = $this->doc->createElement($name);
     }
     if ($parent) {
         $parent->appendChild($el);
     }
     return $el;
 }
开发者ID:medali1990,项目名称:medsite,代码行数:18,代码来源:WSDLStruct.class.php

示例2: domDocument

<?php

$document = new domDocument("1.0", "utf-8");
$domimp = new domImplementation();
$doctype = $domimp->createDocumentType('asortiment[<!ENTITY y1 "2009"> <!ENTITY y2 "2010">]');
$document->appendChild($doctype);
$asortiment = $document->createElementNS("http://mysite.ru", "asort:asortiment");
$document->appendChild($asortiment);
$telefon = $document->createElement("asort:telefon");
$asortiment->appendChild($telefon);
$attr = $document->createAttribute("number");
$attr->nodeValue = 1;
$telefon->appendChild($attr);
$cdata = $document->createCDATASection("Это контент нашего интернет магазина");
$telefon->appendChild($cdata);
$model_1 = $document->createElement("model");
$telefon->appendChild($model_1);
$name_1 = $document->createElement("name");
$model_1->appendChild($name_1);
$textN_1 = $document->createTextNode("Samsung Galaxi");
$name_1->appendChild($textN_1);
$year_1 = $document->createElement("year");
$model_1->appendChild($year_1);
$textY_1 = $document->createTextNode('2009');
$year_1->appendChild($textY_1);
$model_2 = $document->createElement("model");
$telefon->appendChild($model_2);
$name_2 = $document->createElement("name");
$model_2->appendChild($name_2);
$textN_2 = $document->createTextNode("Nokia Lumia");
$name_2->appendChild($textN_2);
开发者ID:echmaster,项目名称:data,代码行数:31,代码来源:dz.php

示例3: domDocument

try {
    $dom = new domDocument();
    $dom->createElementNS('http://www.w3.org/2000/xmlns/', 'xmlns:valid');
    print "valid\n";
} catch (Exception $e) {
    print $e->getMessage() . "\n";
}
print "33 DOMElement::__construct('xmlns:valid', '', 'http://www.w3.org/2000/xmlns/')\n";
try {
    $element = new DomElement('xmlns:valid', '', 'http://www.w3.org/2000/xmlns/');
    print "valid\n";
} catch (Exception $e) {
    print $e->getMessage() . "\n";
}
/* the namespaceURI is "http://www.w3.org/2000/xmlns/" and neither the 
   qualifiedName nor its prefix is "xmlns". */
print "34 DOMDocument::createElementNS('http://www.w3.org/2000/xmlns/', 'wrongprefix:valid')\n";
try {
    $dom = new domDocument();
    $dom->createElementNS('http://www.w3.org/2000/xmlns/', 'wrongprefix:valid');
    print "valid\n";
} catch (Exception $e) {
    print $e->getMessage() . "\n";
}
print "35 DOMElement::__construct('wrongprefix:valid', '', 'http://www.w3.org/2000/xmlns/')\n";
try {
    $element = new DomElement('wrongprefix:valid', '', 'http://www.w3.org/2000/xmlns/');
    print "valid\n";
} catch (Exception $e) {
    print $e->getMessage() . "\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:dom_create_element.php


注:本文中的domDocument::createElementNS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。