I'm trying to parse the 2 <link>
lines between the <entry>
tags but am not able to. The first one is a hyperlink to the user's page, the second is an image link to the user's avatar, both of whih are at the same level.
Please advise how I could go about this.
Thanks!
- Jason
Perfectly solved my problem. Thanks for the quick reply.
- Jason
Hi Jason,
Assuming that you are parsing the XML with the following Format String:
xml|FEED/ENTRY/
...then both
<link>
elements should be present in $record, with the second one having the name LINK@1 (Magic Parser appends @1, @2, etc. to resolve duplicate field names). This can been seen on the following demo page based on the XML that you posted:http://www.magicparser.com/demo?fileID=49D1CDCA3746C&record=1
However, as you cannot be sure which order the links will appear in the record, I would study the -REL attribute to determine which is the main link and which is the avatar URL, using something like this:
function myRecordHandler($record)
{
if ($record["LINK-REL"] == "alternate" && $record["LINK@1-REL"] == "image")
{
$link = $record["LINK-HREF"];
$avatar = $record["LINK@1-HREF"];
}
elseif ($record["LINK-REL"] == "image" && $record["LINK@1-REL"] == "alternate")
{
$link = $record["LINK@1-HREF"];
$avatar = $record["LINK-HREF"];
}
}
Hope this helps!
Cheers,
David.