xml - Only select nodes without a namespace/prefix in PHP DOM? -


i'm trying read rss feeds dom in php one:

    <channel>         <atom:link href='' rel='self' type='application/rss+xml' />         <title>techstuff</title>         <link>http://www.howstuffworks.com</link> 

to grab link (<link></link>) use piece of code:

    $doc->getelementsbytagname('link')->item(0); 

it works in other rss feeds have tried. 1 has placed <atom:link> before <link>, means grabs <atom:link> instead.

so how do select nodes without namespace?

you can tell whether node has namespace checking ->prefix or ->namespaceuri:

foreach ($doc->getelementsbytagname('link') $link) {     if (strlen($link->prefix)) {         continue;     }     // $link not have prefix } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -