I\'m using SimpleXML (Java) and I\'m trying to get a List of objects based on the value of one of the siblings of the list.
So, here\'s my XML:
link
element doesn't have its closing counterpart. The same applies for the description
el. I assume these are just typos./metadata/resources/resource/links/link[parent::links/preceding-sibling::ittype/text()=='Service_Links']
or much simpler version:
/metadata/resources/resource[ittype = 'Service_Links']/links/link
I never got SimpleXml to implement this style of XPath; from reading through their docs more thoroughly, it looks like they haven't implemented this XPath feature yet.
So I settled on a different XML-parsing strategy here: https://stackoverflow.com/a/13236117/483257
I don't know about SimpleXML specifically, but this xpath should get you the elements you want:
metadata/resources/resource[ittype = 'Service_Links']