note 49479 deleted from ref.simplexml by derick
| From: | derick@php.net | Date: | Thu, 13 Oct 2005 13:46:11 +0000 |
| Subject: | note 49479 deleted from ref.simplexml by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96954@lists.php.net to get a copy of this message | ||
Note Submitter: yannis dot haralambous at enst-bretagne dot fr
----
Sometimes tag names do not respect PHP variable name syntax. For example I have a file like this:
<livre>
<éditorial>
<édition-originale ref="123">
bla bla bla
</édition-originale>
</éditorial>
</livre>
It's a perfectly valid XML file, but
$livre->éditorial[0]->édition-originale[0]->attributes()
will not work because of the hyphen.
The only solution I found is to write:
$livre->éditorial[0]->{"édition-originale"}[0]->attributes()
$livre->xpath("/livre/éditorial/édition-originale/@ref") doesn't work either but
for that one I don't know how to solve the problem...