|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
php get rss tag using DOMHi,
I am trying to write a programme to read a rss xml file. ... <media:content url="*exampe.jpg*" ...> ... scan anyone tell me how to get the url attribute? I wrote some codes similar: $doc = new DOMDocument; $doc->load($myFlickrRss); $r = $doc->getElementsByTagName('media:content'); for($i=0;$i<=$r->length;$i++) { // help here } |
|
|
Re: php get rss tag using DOMMorris wrote:
> Hi, > > I am trying to write a programme to read a rss xml file. > > ... > <media:content url="*exampe.jpg*" ...> > ... > > scan anyone tell me how to get the url attribute? I wrote some codes > similar: > > > $doc = new DOMDocument; > $doc->load($myFlickrRss); > > $r = $doc->getElementsByTagName('media:content'); > for($i=0;$i<=$r->length;$i++) { > > // help here > > } > use http://rssphp.net/ you can view the source online and it's all done using DOMDocuments :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: php get rss tag using DOMI know rss_php, but it doesn't fit my solution.
Is anyone able to help me with my question? thx 2009/2/8 Nathan Rixham <nrixham@...> > Morris wrote: > >> Hi, >> >> I am trying to write a programme to read a rss xml file. >> >> ... >> <media:content url="*exampe.jpg*" ...> >> ... >> >> scan anyone tell me how to get the url attribute? I wrote some codes >> similar: >> >> >> $doc = new DOMDocument; >> $doc->load($myFlickrRss); >> >> $r = $doc->getElementsByTagName('media:content'); >> for($i=0;$i<=$r->length;$i++) { >> >> // help here >> >> } >> >> > use http://rssphp.net/ you can view the source online and it's all done > using DOMDocuments :) > |
|
|
Re: php get rss tag using DOMMorris wrote:
> I know rss_php, but it doesn't fit my solution. > > Is anyone able to help me with my question? > > thx > > 2009/2/8 Nathan Rixham <nrixham@...> > >> Morris wrote: >> >>> Hi, >>> >>> I am trying to write a programme to read a rss xml file. >>> >>> ... >>> <media:content url="*exampe.jpg*" ...> >>> ... >>> >>> scan anyone tell me how to get the url attribute? I wrote some codes >>> similar: >>> >>> >>> $doc = new DOMDocument; >>> $doc->load($myFlickrRss); >>> >>> $r = $doc->getElementsByTagName('media:content'); >>> for($i=0;$i<=$r->length;$i++) { >>> >>> // help here >>> >>> } >>> >>> >> use http://rssphp.net/ you can view the source online and it's all done >> using DOMDocuments :) >> > First off, you should be using getElementsByTagNameNS since you are working with a namespaced document. I am assuming its a Yahoo Media RSS feed, so you would get the elements via: $r = $doc->getElementsByTagNameNS("http://search.yahoo.com/mrss/", "content"); Then to output the url attribute value: foreach ($r AS $elem) { echo $elem->getAttribute("url") . "\n"; } Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: php get rss tag using DOMHi. Our site http://rssphp.blogspot.net is working on providing possible solutions to the problem with different parsing methods in PHP. It's worth to have a look at the options. -- List Website |
|
|
Re: php get rss tag using DOMRodgerr wrote:
> > > Morris-25 wrote: >> Hi, >> >> I am trying to write a programme to read a rss xml file. >> >> ... >> <media:content url="*exampe.jpg*" ...> >> ... >> >> scan anyone tell me how to get the url attribute? I wrote some codes >> similar: >> >> >> $doc = new DOMDocument; >> $doc->load($myFlickrRss); >> >> $r = $doc->getElementsByTagName('media:content'); >> for($i=0;$i<=$r->length;$i++) { >> $node = $r->item($i); if ($node->hasAttribute('url') { $url[] = $node->>getAttribute('url'); } >> >> } That should give you an array called $url of all the url attributes in the nodes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: php get rss tag using DOMMichael A. Peters wrote:
> Rodgerr wrote: >> >> >> Morris-25 wrote: >>> Hi, >>> >>> I am trying to write a programme to read a rss xml file. >>> >>> ... >>> <media:content url="*exampe.jpg*" ...> >>> ... >>> >>> scan anyone tell me how to get the url attribute? I wrote some codes >>> similar: >>> >>> >>> $doc = new DOMDocument; >>> $doc->load($myFlickrRss); >>> >>> $r = $doc->getElementsByTagName('media:content'); >>> for($i=0;$i<=$r->length;$i++) { >>> > > $node = $r->item($i); > if ($node->hasAttribute('url') { > $url[] = $node->>getAttribute('url'); > } > >>> >>> } > > That should give you an array called $url of all the url attributes in > the nodes. > $url[] = $node->>getAttribute('url'); should be $url[] = $node->getAttribute('url'); and don't forget to validate it before spitting it back out on a page somewhere ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: php get rss tag using DOMGetting RSS Feeds is going really good right now, what amazing technology :)
Nickname Msn
|
| Free embeddable forum powered by Nabble | Forum Help |