當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。