Kindly take a look at the sample below–
<div class="patent_bibdata">
<b> First list</b>
<a href="1"> Name #1</a>
<a href="2"> Name #2</a>
<b> Second list</b>
<a href="1"> Name #2_1</a>
<a href="2"> Name #2_2</a>
</div>
Now, I want to extract the links after the ‘b’ element that has text “First List”– however, I dont want the links after the ‘b’ element that has text “Second list”– and the number of links after “First List” is not known to me.
What I thought of, is something like this–
....XQuery code defining the document as variable named "doc"
let $list:= $doc/div[ @class="patent_bibdata"]/b[. = 'First list']/following-sibling::text() -- but this should get everything after 'First list'-- including 'Second List' and 'Name #2_1' and 'Name #2_2'
Now, only the text in the 2 ‘b’ tags– (i.e. ‘Name #1’ and ‘Name #2’ in our example) are known to me– so I think I have to somehow put conditions and retrieve the links (that I need), putting conditions on the immediate-predecessor-sibling and immediate-successor-sibling of those links— what are the commands to put those conditions(if I am right so far)? And if I am not right, then how do I go about getting that set of links?
This works:
Considering the amount of rather basic questions you asked today about XQuery it might be advisable to get a fundamental understanding about XQuery first. There are some very good books out there, I especially like the one from Priscilla Walmsley.