terryds Posted June 29, 2013 Share Posted June 29, 2013 (edited) Look at my code below : <?php $xmlData =<<< END<?xml version="1.0"?><datas> <cars> <car> <manufacture country="japan">Honda</manufacture> <type>Honda Jazz</type> </car> <car> <manufacture country="korea">Nissan</manufacture> <type>Nissan Livina</type> </car> </cars></datas>END; $xml = simplexml_load_file($xmlData) or die("Error: Cannot create object"); foreach($xml->children() as $cars){foreach($cars->children() as $car => $data){ echo $data->manufacture['country']; echo "<br />";}} ?> When executed, it gives me an error, can you help me fix that? Edited June 29, 2013 by terryds Link to comment Share on other sites More sharing options...
jeffman Posted June 29, 2013 Share Posted June 29, 2013 (edited) Try simplexml_load_string instead of simplexml_load_file new SimpleXMLElement will work also Edited June 29, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now