I’m trying to get the latest comment from an xml. An example can be found here: http://dev.smoige.com/discussion.xml?DiscussionID=8. I managed to get the LastCommentID which let’s say is 37, can be found in this format <CommentID>37</CommentID> and under that there is this: <Body>this is my damn comment!</Body> which I’m really after. How can I use the LastCommentID to select the right CommentID and get it’s body?
Help please.
$latestXml = 'http://dev.smoige.com/discussion.xml?DiscussionID='.$Discussion->DiscussionID;
if(!$xml=simplexml_load_file($latestXml)){
trigger_error('Error reading XML file',E_USER_ERROR);
}
foreach($xml as $user){
$last = $user->LastCommentID.' ';
}
Thank you
Short answer: XPath.
Here’s a great tutorial:
http://www.phpeveryday.com/articles/PHP-XML-Tutorial-P848.html