가능한 중복 :
A simple program to CRUD node and node values of xml file
XPath and PHP: nothing works properly액세스 요소
$XML = <<<XML
<items>
<item id="123">
<name>Item 1</name>
</item>
<item id="456">
<name>Item 2</name>
</item>
<item id="789">
<name>Item 3</name>
</item>
</items>
XML;
$objSimpleXML = new SimpleXMLElement($XML);
echo $objSimpleXML->item[2]->name; // output: Item 3 (OK)
echo '<br><pre>';
print_r($objSimpleXML->xpath('./item[1]/name')); // output: empty Array!!!
안녕하세요! 순수 xpath 쿼리를 사용하여 "항목 3"을 출력으로 얻는 방법? (내 제안은 빈 배열을 출력합니다.)
이 내용은 http://stackoverflow.com/questions/14280450/xpath-and-php-nothing-works-properly/14280528#14280528과 유사합니다. –