Counting and extracting multiple subfields in an XML entry



In the following example:



<datafield tag="505" ind1="0" ind2="0">
<subfield code="t">Title 1 /</subfield>
<subfield code="r">Responsibility 1.</subfield>
<subfield code="t">Title 2 /</subfield>
<subfield code="r">Responsibility 2.</subfield>
</datafield>


subfields t and r are repeated twice within field tag="505". In a mysql query, it is possible to separately extract each of them (say, the first) via



ExtractValue(marcxml,'//datafield[@tag="505"]/subfield[@code="t"][1]')


with the output



Title 1 /


Would it be possible to know their number (2, in the example above), and loop over that number? I am thinking of something like the dimension of an array.


No comments:

Post a Comment