This is somewhat what my XML looks like:
<?xml version="1.0" encoding="UTF-8"?>
<citizen>
<military>
<rank-points>62750</rank-points>
<stars>1</stars>
<total-damage>18243</total-damage>
<rank>Commander</rank>
<fight-count>0</fight-count>
</military>
</citizen>
Now, I want to import the stuff inside the tag “rank-points” with PHP using
$rank = $xml->{'military'}->rank-points;
But, because the XML tag has a “-” in it’s name, it won’t work. The result is always 0.
Using this :
PHP will actually :
$xml->{'military'}->rankpointsto that value"points".Trying to execute your code, you should actually get a notice, indicating what I said :
To solve that problem, try adding
{''}around the name of your tag :This way, PHP will know that
rank-pointsis one thing — and not a substraction.