I am stumped as to how I can extract the "href" attribute from the "link" tag from this bit of XML using my PHP parsing script. If it helps at all, I am trying to extract the URL of a particular post from a GetSatisfaction API feed.
Here is an example a node from the XML file:
<entry>
<link rel="something" href="http://...url_I_need" type="text/html"/>
<title type="html">...title here...</title>
<content type="html">
...content here...
</content>
</entry>
And here is the data gathering portion of my PHP XML parsing script:
$doc = new DOMDocument();
$doc->load('http://api.getsatisfaction.com/companies/issuetrak/topics?sort=recently_active&limit=7');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('entry') as $node) {
$title = $node->getElementsByTagName('title')->item(0)->nodeValue;
//I need to just store the link->href value to $link below
//$link = ???;
}
Any suggestions on how to extract that "href" attribute?
Thanks!
What about DOMElement::getAttribute
?
$href = $node->getElementsByTagName('link')->item(0)->getAttribute('href');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With