- var_dump: documentation ( source)
- simplexml_load_string: documentation ( source)
<?php
$file = <<<XML
<?xml version="1.0"?>
<?xml-stylesheet href="catalog.xsl" type="text/xsl"?>
<!DOCTYPE catalog SYSTEM "catalog.dtd">
<catalog>
<product description="Cardigan Sweater" id="123" value="" product_image="cardigan.jpg">
<catalog_item gender="Men's">
<size description="Medium">
<color_swatch image="red_cardigan.jpg" id="color" value="Red"/>
<color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/>
</size>
<size description="Large">
<color_swatch image="red_cardigan.jpg" id="color" value="Red"/>
<color_swatch image="burgundy_cardigan.jpg" id="color" value="burgundy"/>
</size>
</catalog_item>
</product>
</catalog>
XML;
$xml = simplexml_load_string($file);
foreach($xml as $product) {
var_dump($product);
}