note 49479 added to ref.simplexml
| From: | yannis dot haralambous at enst-bretagne dot fr | Date: | Sat, 29 Jan 2005 20:44:11 +0000 |
| Subject: | note 49479 added to ref.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84164@lists.php.net to get a copy of this message | ||
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...
----
Manual Page -- http://www.php.net/manual/en/ref.simplexml.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49479
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49479&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49479&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49479&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49479&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49479&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49479&report=yes
Search -- http://master.php.net/manage/user-notes.php