PHP and XML: How to deal with ":" in node name? [duplicate]




This question already has an answer here:




I have XML file:



<article>
<itam:name>Title</itam:name>
<itam:link>url_to_itam</itam:link>
</article>


And a PHP script that generate file from that xml feed:



<?php
$file = "file.php";
$html = "";
$url = "http://ift.tt/13ImNq3";
$xml = simplexml_load_file($url);
for($i = 0; $i < 10; $i++){
$link = $xml->article[$i]->itam:link;
$title = $xml->article[$i]->itam:name;
$html .= "<a href=\"$link\">$title</a>";
}
file_put_contents($file, $html);
?>


This script is working for other feeds but not for that one, I'm getting error:



PHP Parse error: syntax error, unexpected ':'


What I can do with ":" in node name?


No comments:

Post a Comment