XML tag with hyphens


This took me a little while to work out. I’m using PHP5’s SimpleXML to parse XML into a PHP object. The XML has entries like <first-name>.

But you can’t use $xml->first-name because it reads the hyphen as a minus.

Instead, use $xml->{‘first-name’}

Cheers!

Advertisements