Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attributes

Status
Not open for further replies.

foddski

Programmer
Jul 20, 2008
3
GB
Hi I'm struggling to get to the child nodes within a parent with a specific attribute. I want to do this
$word=$xml->xpath("//page[@name='$page']")->word; but can't.
where $page is 'the xml file has the format
Code:
<?xml version="1.0" encoding="UTF-8"?>
<keywords>
	<page name="[URL unfurl="true"]http://www.domain.co.uk">[/URL]
		<word frequency="1">hello</word>
		<word frequency="2">world</word>
	</page>
	<page name="[URL unfurl="true"]http://www.domain.co.uk/contact.php">[/URL]
		<word frequency="1">hello</word>
		<word frequency="2">world</word>
	</page>
</keywords>
Any tips would be appreciated
 
>$word=$xml->xpath("//page[@name='$page']")->word
[tt]$word=$xml->xpath("//page[@name='$page']/word")[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top