<?php
$xmlstr = <<<XML
<?xml version='1.0' standalone='yes'?>
<reports>
<report id="1"/>
</reports>
XML;
?>
Accessing the id is attribute is done this way
$xml = new SimpleXMLElement($xmlstr);
$id = (string) $xml->report["id"];
If you forget the cast (string) you got an illegal offset warning, wich is due to the fact that attributes themselves are simpleXMLElement.
Aucun commentaire:
Enregistrer un commentaire