I use entities in XML and I don't understand my results.
I have an XML file wich calls an external entity, this is config.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE config [
<!ENTITY totalInstances SYSTEM "totalInstances.xml">
]>
<config>
&totalInstances;
</config>
Here is the file totalInstances.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<totalInstances>
<nombre>45</nombre>
</totalInstances>
So in PHP I load the file config.xml with the help of the Class SimpleXMLElement :
$config = simplexml_load_file('config.xml');
Then I output the variable $config with a var_dump, and here is the thing I don't understand :
object(SimpleXMLElement)[3]
public 'totalInstances' =>
object(SimpleXMLElement)[5]
public 'totalInstances' =>
object(SimpleXMLElement)[6]
public 'totalInstances' =>
object(SimpleXMLElement)[8]
public 'nombre' => string '45' (length=2)
I expected to have a simple "totalInstances" node which contains the node "nombre" . What happens ? Thanks you.
edit : For more details, I don't understand why I get three objects named "totalInstances" while there are only one in the file totalInstances.xml ? I expected to have this output :
object(SimpleXMLElement)[3]
public 'totalInstances' =>
object(SimpleXMLElement)[8]
public 'nombre' => string '45' (length=2)
Also, I'm not sure to understand what means the number between the "[]" in the output.