当前位置: 首页>>代码示例>>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;未经允许,请勿转载。