<?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);
}
- Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- object(SimpleXMLElement)#3 (2) {
["@attributes"]=>
array(4) {
["description"]=>
string(16) "Cardigan Sweater"
["id"]=>
string(3) "123"
["value"]=>
string(0) ""
["product_image"]=>
string(12) "cardigan.jpg"
}
["catalog_item"]=>
object(SimpleXMLElement)#4 (2) {
["@attributes"]=>
array(1) {
["gender"]=>
string(5) "Men's"
}
["size"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#5 (2) {
["@attributes"]=>
array(1) {
["description"]=>
string(6) "Medium"
}
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#7 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(16) "red_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(3) "Red"
}
}
[1]=>
object(SimpleXMLElement)#8 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(21) "burgundy_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(8) "burgundy"
}
}
}
}
[1]=>
object(SimpleXMLElement)#6 (2) {
["@attributes"]=>
array(1) {
["description"]=>
string(5) "Large"
}
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#8 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(16) "red_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(3) "Red"
}
}
[1]=>
object(SimpleXMLElement)#7 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(21) "burgundy_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(8) "burgundy"
}
}
}
}
}
}
}
- Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17
- object(SimpleXMLElement)#3 (2) {
["@attributes"]=>
array(4) {
["description"]=>
string(16) "Cardigan Sweater"
["id"]=>
string(3) "123"
["value"]=>
string(0) ""
["product_image"]=>
string(12) "cardigan.jpg"
}
["catalog_item"]=>
object(SimpleXMLElement)#4 (2) {
["@attributes"]=>
array(1) {
["gender"]=>
string(5) "Men's"
}
["size"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#5 (2) {
["@attributes"]=>
array(1) {
["description"]=>
string(6) "Medium"
}
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#7 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(16) "red_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(3) "Red"
}
}
[1]=>
object(SimpleXMLElement)#8 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(21) "burgundy_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(8) "burgundy"
}
}
}
}
[1]=>
object(SimpleXMLElement)#6 (2) {
["@attributes"]=>
array(1) {
["description"]=>
string(5) "Large"
}
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#9 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(16) "red_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(3) "Red"
}
}
[1]=>
object(SimpleXMLElement)#10 (1) {
["@attributes"]=>
array(3) {
["image"]=>
string(21) "burgundy_cardigan.jpg"
["id"]=>
string(5) "color"
["value"]=>
string(8) "burgundy"
}
}
}
}
}
}
}
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
- object(SimpleXMLElement)#3 (1) {
["catalog_item"]=>
object(SimpleXMLElement)#4 (1) {
["size"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#5 (1) {
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#7 (0) {
}
[1]=>
object(SimpleXMLElement)#8 (0) {
}
}
}
[1]=>
object(SimpleXMLElement)#6 (1) {
["color_swatch"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#9 (0) {
}
[1]=>
object(SimpleXMLElement)#10 (0) {
}
}
}
}
}
}
- Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: simplexml_load_string() in /in/jlLkh on line 23
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.1, 4.4.3 - 4.4.4
- Fatal error: Call to undefined function: simplexml_load_string() in /in/jlLkh on line 23
Process exited with code 255. - Output for 4.4.2
- Fatal error: Call to undefined function: simplexml_load_string() in /in/jlLkh on line 24
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: simplexml_load_string() in /in/jlLkh on line 23
preferences:
61.54 ms | 418 KiB | 5 Q