downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DOMNode::hasAttributes> <DOMNode::getLineNo
[edit] Last updated: Fri, 25 May 2012

view this page in

DOMNode::getNodePath

(PHP 5 >= 5.2.0)

DOMNode::getNodePathノードの XPath を取得する

説明

public string DOMNode::getNodePath ( void )

ノードの XPath ロケーションパスを取得します。

パラメータ

この関数にはパラメータはありません。

返り値

XPath を含む文字列、あるいはエラー時に NULL を返します。

例1 DOMNode::getNodePath() の例

<?php
// 新しい DOMDocument インスタンスを作ります
$dom = new DOMDocument;

// XML を読み込みます
$dom->loadXML('
<fruits>
 <apples>
  <apple>braeburn</apple>
  <apple>granny smith</apple>
 </apples>
 <pears>
  <pear>conference</pear>
 </pears>
</fruits>
'
);

// 各要素の XPath を表示します
foreach ($dom->getElementsByTagName('*') as $node) {
    echo 
$node->getNodePath() . "\n";
}
?>

上の例の出力は以下となります。

/fruits
/fruits/apples
/fruits/apples/apple[1]
/fruits/apples/apple[2]
/fruits/pears
/fruits/pears/pear

参考



add a note add a note User Contributed Notes DOMNode::getNodePath
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites