0

I have a XML document that looks something like this:

<?xml version="1.0" encoding="UTF-8"?> 
<citizen> 
  <military-skills> 
    <military-skill> 
      <level>Marksman</level> 
      <points>1620.735</points> 
      <name>Strength</name> 
    </military-skill> 
  </military-skills> 
</citizen> 

I want to get the value from the tag "points" using PHP SimpleXML.
In another place, I read I could use "$xml->children()->points;" but it ain't working.

If anyone wonders, this is the XML document I want to import.

Snacker
  • 29
  • 4
  • 1
    You need an XML parser. [Here](http://stackoverflow.com/questions/1706042/how-to-parse-xml-file-in-php) is a good overview. – Pekka Apr 09 '11 at 22:41

1 Answers1

0

You can do this quite simply with SimpleXML:

$xml = new SimpleXMLElement('file.xml', 0, true);
$points = $xml->{'military-skills'}->{'military-skill'}->points;
// You can then convert $points to double or float