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 whic
Try this XPath:
/object/data[@type="me"]
Which reads as:
/) children of the current element called object/) their children called data[...]) that list to elements where ...
type (the @ means "attribute")meSo:
$myDataObjects = $simplexml->xpath('/object/data[@type="me"]');
If object is not the root of your document, you might want to use //object/data[@type="me"] instead. The // means "find all descendents" rather than "find all children".