SimpleXML - parsing attributes with a namespace
| From: | Anthony Gladdish | Date: | Thu, 02 Jun 2011 09:44:10 +0000 |
| Subject: | SimpleXML - parsing attributes with a namespace | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-313327@lists.php.net to get a copy of this message | ||
Hi,
Using following code does not parse the "xml:id" attribute. If I change the
attribute's namespace to anything other than "xml" ( e.g. "new:id" ) then
it works.
$string = <<<XML
<TEI xml:id="decten1tlsg01">
<teiHeader>
<profileDesc>
<particDesc>
<person xml:id="interviewerTlsg01"> </person>
</particDesc>
</profileDesc>
</teiHeader>
</TEI>
XML;
$xml = simplexml_load_string($string);
foreach($xml->teiHeader->profileDesc->particDesc->person[0]->attributes() as $a =>
$b) {
echo "<p>$a = $b \n</p>";
}
Is this a bug? And how do I get this to work?
Many thanks,
Anthony