Reputation: 5316
I have a xml file
<events date="30/08/2010">
<event>
<title>here</title>
<description>
This is first Event This is first Event This is first Event This is first Event This is first Event This is first Event This is first Event This is first Event This is first Event This is first Event
</description>
</event>
</events>
<events date="31/08/2010">
<event>
<title>Second Event </title>
<description>
Second Event Second Event Second Event Second Event Second Event Second Event Second Event Second Event Second Event Second Event
</description>
</event>
</events>
from this xml how i can select the event with title Second Event using xquery.I used
$nodes = $xml->xpath('//xml/events/event[@title="'.$title.'"]');
but it is not working, can anybody help me
Upvotes: 0
Views: 187
Reputation: 5316
$nodes = $xml->xpath('//xml/events/event[title="'.$title.'"]');
Upvotes: 0
Reputation: 2471
You don't have a node called "xml" so your query should not start "xml". Title is not an attribute, so remove the "@". This (untested) ought to work:
//events/event[title="'.$title.'"]'
and return a node list.
Upvotes: 2