Jump to content

tag name syntax


nickjonnes

Recommended Posts

hey all,

here is the xml code

 

<title>Dogged determination</title>    
<link rel="alternate" href="http://video.news.com.au/1959670201/Dogged-determination" />    
<author>      
<name>mr mittens</name>    
</author>

 

now to parse this to get the title i would do this but what if i want the link?

 

<?php$feed = simplexml_load_file('http://video.news.com.au/feed.atom');$link = (string) $feed->entry->title;echo $link;?>

 

but what do i do to get the 'link'?

i tried link an that obviously didnt work.

cheers nick

 

Link to comment
Share on other sites

I was looking for my two day old post with no replies and I found yours so here is my 2 cents.

 

I am not 100% sure and I may be way off base but it seems to work in my head and my syntax for preg_match may not be right on either. I don't use reg-ex that often.

 

<?php

$feed = simplexml_load_file('http://video.news.com.au/feed.atom');
$pattern = '/href="(.)*"/';
$link = preg_match($pattern, $feed->entry->link);

echo $link;

?>

Link to comment
Share on other sites

<?php

$xml = simplexml_load_file('http://video.news.com.au/feed.atom');

foreach( $xml->entry as $entry ) {

echo "Title - {$entry->title}<br>";
echo "Link - {$entry->link->attributes()->href}<br>";
echo "Summary - {$entry->summary}<br><br>";

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.