Google News
logo
XML - Interview Questions
How to get attribute value in XML using php?
<?php

$XML=simpleXML_Load_file(“saleslist.XML”) or die(“Error: cannot create object”);

for ($x=0; $x<6; $x++)

echo $XML — > book[$x] — > title[‘bookname’] . “<br>”;

?>
saleslist.XML – is the name of the file we are calling using PHP.
 
bookname – is the item we are calling for output. 
 
Here, x is the attribute.
Advertisement