Michael A. Peters wrote:
Rodgerr wrote:

Morris-25 wrote:

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

 $doc = new DOMDocument;

 $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

Reply via email to