Example of XML: Retrieving Attribute Values by PHP
First, create xml document like this:
05 | <manufacture country="japan">Honda</manufacture> |
06 | <type>Honda Jazz</type> |
09 | <manufacture country="korea">Nissan</manufacture> |
10 | <type>Nissan Livina</type> |
Save as "cars.xml" within www/test/xml. Then create reader like this:
02 | $xml = simplexml_load_file("cars.xml") |
03 | or die("Error: Cannot create object"); |
05 | foreach($xml->children() as $cars){ |
06 | foreach($cars->children() as $car => $data){ |
07 | echo $data->manufacture['country']; |
No comments:
Post a Comment