本文整理汇总了PHP中domDocument::createTextNode方法的典型用法代码示例。如果您正苦于以下问题:PHP domDocument::createTextNode方法的具体用法?PHP domDocument::createTextNode怎么用?PHP domDocument::createTextNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类domDocument
的用法示例。
在下文中一共展示了domDocument::createTextNode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
$newnode = $doc->createElement($key, $val);
$doc->appendChild($newnode);
$add = $doc->getElementsByTagName('PROBLEM')->item(0);
$add->appendChild($newnode);
break;
//********************************** SET_OF_SOLUTIONS *************************************
//********************************** SET_OF_SOLUTIONS *************************************
case $key == 'pattern_solution_name':
$newnode = $doc->createElement($key, $val);
$doc->appendChild($newnode);
$add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
$add->appendChild($newnode);
break;
case $key == 'objectives':
$newnode = $doc->createElement($key);
$noeud = $doc->createTextNode($val);
$doc->appendChild($newnode);
$add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
$add->appendChild($newnode);
break;
case $key == 'pattern_indicators':
$newnode = $doc->createElement($key, $val);
$doc->appendChild($newnode);
$add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
$add->appendChild($newnode);
break;
case $key == 'pattern_methods':
$newnode = $doc->createElement($key, $val);
$doc->appendChild($newnode);
$add = $doc->getElementsByTagName('SET_OF_SOLUTIONS')->item(0);
$add->appendChild($newnode);
示例2: nl2br
<?php
$dom = new domDocument('1.0');
$dom->formatOutput = true;
// make output be nicely formatted
$root = $dom->createElement('root');
// create new element
foreach (array('foo', 'bar', 'baz') as $v) {
$node = $dom->createElement($v);
// create new sub-element
$node->appendChild($dom->createTextNode($v));
// add value to element
$root->appendChild($node);
// append sub-element to root element
}
$dom->appendChild($root);
// add root node to document
$xml = $dom->saveXML();
// output XML
echo nl2br(htmlspecialchars($xml));
示例3:
$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);
$year_2 = $document->createElement("year");
$model_2->appendChild($year_2);
$textY_2 = $document->createTextNode('2010');
$year_2->appendChild($textY_2);
示例4: getTextBetweenTags
/**
*
* @get text between tags
* @param string $tag The tag name
* @param string $html The XML or XHTML string
* @param int $strict Whether to use strict mode
* @param string $encoding
* @return array
*/
private function getTextBetweenTags($tag, $html, $strict = 0, $encoding = "UTF-8")
{
global $PAGE, $CFG;
if (!isset($CFG->filter_jsxgraph_divid)) {
set_config('filter_jsxgraph_divid', 'box');
}
if (!isset($CFG->filter_jsxgraph_boardvar)) {
set_config('filter_jsxgraph_boardvar', 'board');
}
if (!isset($CFG->filter_jsxgraph_width)) {
set_config('filter_jsxgraph_width', '500');
}
if (!isset($CFG->filter_jsxgraph_height)) {
set_config('filter_jsxgraph_height', '400');
}
// a new dom object
$dom = new domDocument();
$dom->formatOutput = true;
// load the html into the object
if ($strict == 1) {
$dom->loadXML($html);
} else {
libxml_use_internal_errors(true);
$htmlutf8 = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding);
$dom->loadHTML($htmlutf8);
libxml_use_internal_errors(false);
}
// discard white space
$dom->preserveWhiteSpace = false;
$dom->strictErrorChecking = false;
$dom->recover = true;
// the tag by its tag name
$content = $dom->getElementsByTagname($tag);
if (count($content) > 0) {
$PAGE->requires->js(new moodle_url($CFG->wwwroot . '/filter/jsxgraph/jsxgraphcore.js'));
}
// Iterate backwards through the jsxgraph tags
$i = $content->length - 1;
while ($i > -1) {
$item = $content->item($i);
// Read attributes
$w = $item->getAttribute('width');
if ($w == "") {
$w = $CFG->filter_jsxgraph_width;
}
$h = $item->getAttribute('height');
if ($h == "") {
$h = $CFG->filter_jsxgraph_height;
}
$b = $item->getAttribute('box');
if ($b == "") {
$b = $CFG->filter_jsxgraph_divid . $i;
}
$brd = $item->getAttribute('board');
if ($brd == "") {
$brd = $CFG->filter_jsxgraph_boardvar . $i;
}
/* Create new div element containing JSXGraph */
$out = $dom->createElement('div');
$a = $dom->createAttribute('id');
$a->value = $b;
$out->appendChild($a);
$a = $dom->createAttribute('class');
$a->value = "jxgbox";
$out->appendChild($a);
$a = $dom->createAttribute('style');
$a->value = "width:" . $w . "px; height:" . $h . "px; ";
$out->appendChild($a);
$t = $dom->createTextNode("");
$out->appendChild($t);
$out = $dom->appendChild($out);
// Replace <jsxgraph> by <div>
$item->parentNode->replaceChild($out, $item);
$code = "";
$needGXT = false;
$url = $item->getAttribute('file');
if ($url != "") {
$code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromFile('" . $b . "', '" . $url . "', 'Geonext');";
$needGXT = true;
} else {
$url = $item->getAttribute('filestring');
if ($url != "") {
$code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromString('" . $b . "', '" . $url . "', 'Geonext');";
$needGXT = true;
} else {
// Plain JavaScript code
$code = $item->nodeValue;
}
}
// Place JavaScript code at the end of the page.
$PAGE->requires->js_init_call($code);
//.........这里部分代码省略.........
示例5: domDocument
\t<userburo>
\t</userburo>
</bureau>
XML;
$dom = new domDocument();
$dom->loadXML($xmlPrefs);
if (!$dom) {
echo 'Erreur de traitement XML';
exit;
}
$frstN = array("wallpaper", "pos_wallpaper", "iconsize", "iconsfield", "bgcolor", "quicklaunch", "s_idart", "winsize", "data");
$liste = $dom->getElementsByTagName('userburo');
$neud = $liste->item(0);
foreach ($frstN as $thisN) {
${$thisN} = $dom->createElement($thisN);
${$thisN}->appendChild($dom->createTextNode($_POST[$thisN]));
$neud->appendChild(${$thisN});
}
foreach ($_POST['icons'] as $k => $val) {
$noeud = $liste->item(0);
$node = $dom->createElement("icon");
foreach ($val as $k1 => $val1) {
$icon_x = $dom->createElement($k1, $val1);
$node->appendchild($icon_x);
}
$noeud->appendChild($node);
}
$s = simplexml_import_dom($dom);
// ecriture du fichier
$filexml = 'PREFS_' . $login . '.xml';
file_put_contents('/home/' . $login . '/Profile/' . $filexml, $s->asxml());
示例6: domAttr
echo $element_2->nodeValue . "<br/>";
echo "---------------------------------------*<br/>";
$attr_1 = $document->createAttribute("attr_1");
$attr_1->nodeValue = 20;
$attr_2 = new domAttr("attr_2", 64);
echo $attr_1->nodeName . "<br>";
echo $attr_2->nodeName . "<br>";
echo $attr_1->nodeValue . "<br/>";
echo $attr_2->nodeValue . "<br/>";
echo "---------------------------------------*<br/>";
$cdata_1 = $document->createCdataSection("Section CDATA 1");
$cdata_2 = new domCdataSection("Section CDATA 2");
echo $cdata_1->nodeValue . "<br/>";
echo $cdata_2->nodeValue . "<br/>";
echo "---------------------------------------*<br/>";
$text_1 = $document->createTextNode("Text Node 1");
$text_2 = new domText("Text Node 2");
echo $text_1->nodeValue . "<br/>";
echo $text_2->nodeValue . "<br/>";
echo "---------------------------------------*<br/>";
$comment_1 = $document->createComment("Comment 1");
$comment_2 = new domComment("Comment 2");
echo $comment_1->nodeValue . "<br/>";
echo $comment_2->nodeValue . "<br/>";
echo "<br/>*---------------------------------------*<br/><br/>";
$comment = $document->createComment("This is document");
$document->appendChild($comment);
$root = $document->createElement("root");
$document->appendChild($root);
$element1 = $document->createElement("el1");
$element2 = $document->createElement("el2");