Parsing XML

What do you normally use for parsing XML? (not RSS)

I’m coding for 5.1.3

A lot of the “getting started” guides I’m finding just lead me right back to the PHP manual pages, so my searching hasn’t been all that helpful.

In the manual pages, there appears to be a few different readers to choose from. What’s easiest to use? Are there some examples on how to use them?

Thanks :slight_smile:

You can use simplexml_load_string or simplexml_load_file to interpret a string/file of XML into an object

$xml = simplexml_load_string($string_of_xml);

$xml = simplexml_load_file('test.xml');

print_r($xml) or var_dump($xml) will output like this:

SimpleXMLElement Object
  [tag1] => value of tag1
  [tag2] => value of tag2

Bingo, that did the trick, thanks :slight_smile:

This helped with some of the syntax: