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


PHP domDocument::loadxml方法代碼示例

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


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

示例1: bench2

function bench2()
{
    global $XML;
    $dom = new domDocument();
    $dom->loadxml($XML);
    $children = $dom->getElementsByTagName('title');
    foreach ($children as $v) {
        $arr[] = $v->nodeValue;
    }
    return $arr;
}
開發者ID:michaelprem,項目名稱:phc,代碼行數:11,代碼來源:domxml_php5.inc.php

示例2: bench2

function bench2()
{
    global $XML;
    $dom = new domDocument();
    $dom->loadxml($XML);
    $xp = new domxpath($dom);
    $nodes = $xp->query("//title/text()");
    foreach ($nodes as $n) {
        $arr[] = $n->nodeValue;
    }
    return $arr;
    /*
    // simplexml syntax...
    $s = simplexml_load_string($XML);
    $nodes = $s->xpath("//title");
    foreach($nodes as $v) {
    	$arr[] = reset($v);
    }
    return $arr;
    */
}
開發者ID:michaelprem,項目名稱:phc,代碼行數:21,代碼來源:xpath_php5.inc.php

示例3: domDocument

<?php

require_once "dom1.inc";
echo "Test 1: accessing single nodes from php\n";
$dom = new domDocument();
$dom->loadxml($xmlstr);
if (!$dom) {
    echo "Error while parsing the document\n";
    exit;
}
// children() of of document would result in a memleak
//$children = $dom->children();
//print_node_list($children);
echo "--------- root\n";
$rootnode = $dom->documentElement;
print_node($rootnode);
echo "--------- children of root\n";
$children = $rootnode->childNodes;
print_node_list($children);
// The last node should be identical with the last entry in the children array
echo "--------- last\n";
$last = $rootnode->lastChild;
print_node($last);
// The parent of this last node is the root again
echo "--------- parent\n";
$parent = $last->parentNode;
print_node($parent);
// The children of this parent are the same children as one above
echo "--------- children of parent\n";
$children = $parent->childNodes;
print_node_list($children);
開發者ID:cefalo19,項目名稱:php-src,代碼行數:31,代碼來源:dom1.php

示例4: domDocument

<?php

$xml = '<?xml version="1.0"?><dependencies><dependency dependency_id="0" dependent_id="1"/><dependency dependency_id="4" dependent_id="5"/><dependency dependency_id="5" dependent_id="6"/><dependency dependency_id="9" dependent_id="8"/><dependency dependency_id="10" dependent_id="8"/><dependency dependency_id="12" dependent_id="13"/><dependency dependency_id="12" dependent_id="14"/></dependencies>';
$dom = new domDocument();
$dom->loadxml($xml);
$xpath = new DOMXPath($dom);
$node_list = $xpath->query('//dependencies/dependency[@dependency_id = 0 and @dependent_id = 1]');
$dependencies = $xpath->query('//dependencies')->item(0);
$dependencies->removeChild($node_list->item(0));
開發者ID:badlamer,項目名稱:hhvm,代碼行數:9,代碼來源:1670.php


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