In an XML document, I have elements which share the same name, but the value of an attribute defines what type of data it is, and I want to select all of those elements which have a certain value from the document. Do I need to use XPath (and if so, could you suggest the right syntax) or is there a more elegant solution?
Here's some example XML:
Try this XPath:
$myDataObjects = $simplexml->xpath('/object/data[@type="me"]');
object is not the root of your document, use