select single node from Xpath query

hoangtutm

New Member
I'm using this code to extract all required nodes from xml:\[code\]$xml = simplexml_load_file('file.xml'); echo "<strong>Using direct method...</strong><br />"; $items = $xml->xpath('/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/w:t'); foreach($items as $item) { echo "Found $item<br />"; }\[/code\]I'm getting a long list of entries, but I need possibility to choose any of them seperately. tried to use \[code\]echo "Found $item[2]<br />";\[/code\] but got error:\[quote\] \[code\]Warning: main() [function.main]: Cannot add element t number 1 when only 0 such elements exist\[/code\]thanks for advices\[/quote\]
 
Back
Top