Posted Thursday, 15th October 2009 11:50 » Permalink

Using dashes in XML tags and attributes?

I came across an XML file that had dashed attribute names:

<node attribute-name="dashed" />

This makes PHP's parser a bit unhappy if you try and access the attribute using:

$xml->attribute()->attribute-name

Fix it with some curly brackets: $node->attribute()->{'attribute-name'}.

Hurrah!

Tagged: and

« Localisation in jQuery Datepicker Chroma Agency win 2009 WebAward »