Reputation: 1161
I make a JAVA program to parse xml file like this exemple :
<lom:contribute>
<lom:role>
<lom:source>LOMv1.0</lom:source>
<lom:value>author</lom:value>
</lom:role>
<lom:entity>toto</lom:entity>
<lom:date>
<lom:dateTime>2009-10-07</lom:dateTime>
</lom:date>
</lom:contribute>
<lom:contribute>
<lom:role>
<lom:source>LOMv1.0</lom:source>
<lom:value>instructional designer</lom:value>
</lom:role>
<lom:entity>titi</lom:entity>
<lom:date>
<lom:dateTime>2009-10-07</lom:dateTime>
</lom:date>
</lom:contribute>
I would like to make XPath query to get the entity (toto in this exemple) when the role value is author. I have make this query for the moment : //*[local-name()='contribute']/*[local-name()='role']/*[local-name()='value'] = 'author'
. This query return true if author was present in file but I don't know how to get entity value.
Thanks in advance.
Upvotes: 0
Views: 302
Reputation: 1133
This XPath returns toto
:
//*[local-name()='contribute'][*[local-name()='role']/*[local-name()='value'] = 'author']/*[local-name()='entity']/text()
If you remove the last /text()
, it returns the entity
element containing the text toto
. I'm not sure which of them are you looking for.
Upvotes: 1