의 값을 얻으려면?href 속성의 값을 얻는 방법은 무엇입니까? 다음과 같은 경우에 href 속성의 값을 취득하는 방법의 XPath의 도움으로
<a href="http://foo.com">a wrong one</a>
<a href="http://example.com">the right one</a>
<a href="http://boo.com">a wrong one</a>
이다 (단지 바로 하나의 URL을 잡아) 링크에 특정 텍스트가있는 경우 href 속성
$xml = '<html><a href="http://foo.com">a wrong one</a>'
. '<a href="http://example.com">the right one</a>'
. '<a href="http://boo.com">a wrong one</a></html>';
$tree = simplexml_load_string($xml);
$nodes = $tree->xpath('//a[text()="the right one"]');
$href = (string) $nodes[0]['href'];
* "XPath의 도움을 받아"*로 시작하는 질문은 아닙니까? –