當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DomDocument::createCdataSection方法代碼示例

本文整理匯總了PHP中DomDocument::createCdataSection方法的典型用法代碼示例。如果您正苦於以下問題:PHP DomDocument::createCdataSection方法的具體用法?PHP DomDocument::createCdataSection怎麽用?PHP DomDocument::createCdataSection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DomDocument的用法示例。


在下文中一共展示了DomDocument::createCdataSection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

$htext = $doc->createTextNode($_POST['headline']);
$head->appendChild($htext);
//create navlabel
$head = $doc->createElement("navigationlabel");
$root->appendChild($head);
$htext = $doc->createTextNode($_POST['navlabel']);
$head->appendChild($htext);
//create abstract
$abs = $doc->createElement("description");
$root->appendChild($abs);
$abstext = $doc->createTextNode($_POST['description']);
$abs->appendChild($abstext);
//create body
$body = $doc->createElement("body");
$root->appendChild($body);
$cdata = $doc->createCdataSection($_POST['body']);
$body->appendChild($cdata);
//create status
$stat = $doc->createElement("status");
$root->appendChild($stat);
$stext = $doc->createTextNode($_POST['status']);
$stat->appendChild($stext);
//create pubDate
$pub = $doc->createElement("pubdate");
$root->appendChild($pub);
$pubtext = $doc->createTextNode($_POST['pubDate']);
$pub->appendChild($pubtext);
//write to the file
$filename = "../xml/" . $id . ".xml";
$doc->save($filename);
header("Location:webcopytool.php");
開發者ID:iplaydu,項目名稱:xml1,代碼行數:31,代碼來源:addCopy.php

示例2:

$atext = $doc->createTextNode($_POST['authorid']);
$author->appendChild($atext);
//create categoryID
$cat = $doc->createElement("categoryid");
$root->appendChild($cat);
$ctext = $doc->createTextNode($_POST['categoryid']);
$cat->appendChild($ctext);
//create abstract
$abs = $doc->createElement("url");
$root->appendChild($abs);
$abstext = $doc->createTextNode($_POST['url']);
$abs->appendChild($abstext);
//create body
$body = $doc->createElement("description");
$root->appendChild($body);
$cdata = $doc->createCdataSection($_POST['description']);
$body->appendChild($cdata);
//create keywords
$key = $doc->createElement("keywords");
$root->appendChild($key);
$ktext = $doc->createTextNode($_POST['keywords']);
$key->appendChild($ktext);
//create status
$stat = $doc->createElement("status");
$root->appendChild($stat);
$stext = $doc->createTextNode($_POST['status']);
$stat->appendChild($stext);
//create expireDate
$ex = $doc->createElement("expiredate");
$root->appendChild($ex);
$xtext = $doc->createTextNode($_POST['expiredate']);
開發者ID:iplaydu,項目名稱:xml1,代碼行數:31,代碼來源:updateNews.php


注:本文中的DomDocument::createCdataSection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。