What should xPath use to display the requested data?

advertisements

I am using the following script to get the POST TITLE and the CONTENT of an RSS feed. The structure of it is: ( I guess i did not make any error)

<div id="feedBody">
<div id="feedContent">
<div class="entry">
<h3>TITLE OF POST</h3>
<div base="http://feeds.feedburner.com/blogspot/hyMBI"
     class="feedEntryContent"
    > CONTENT OF POST </div>
</div>
</div>
</div>

<?php
$dom = new DOMDocument;
libxml_use_internal_errors(TRUE);
$dom->loadHTMLFile('http://feeds.feedburner.com/blogspot/hyMBI');
libxml_clear_errors();

$xPath = new DOMXPath($dom);
$links = $xPath->query('????????????????');
foreach($links as $link) {
    printf("%s \n", $link->nodeValue);
}
?>

What xPath should I use to get the data? Is there any way of having them seperate? Thanks a million, hopefully this is my last question on my project...


First, you should load the XML using load, not loadHTMLFile.

Judging by your variable name "$links", I guess you're wanting the values of the <link> elements inside the <item> elements. So construct an xpath query that says just that: //item/link.