Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath Function looking for "CC130"

Tags:

xml

xpath

Hi im trying to work out what the function would be to just showcase all the books which are on course "CC130" for example?

i have this "/bookcollection/items/item/courses/course" which shows every course possible?

     <?xml version="1.0" encoding="utf-8"?>
     <bookcollection>
     <item id="59113">  
     <title>Computer science : a modern introduction /</title>
     <isbn>0131659456</isbn>
     <url>http://library.hud.ac.uk/catlink/bib/59113</url>
     <borrowedcount>29</borrowedcount>
     <courses>
        <course>CC100</course>
        <course>CC130</course>
        <course>CX290</course>
     </courses>
  </item>
  <item id="59118">
     <title>Computer networks : protocols, standards, and interfaces /</title>
     <isbn>0131660918</isbn>
     <url>http://library.hud.ac.uk/catlink/bib/59118</url>
     <borrowedcount>19</borrowedcount>
     <courses>
        <course>CC100</course>
     </courses>
  </item>
  <item id="59131">
     <title>Computer-based instruction : methods and development /</title>
     <isbn>0131685929</isbn>
     <url>http://library.hud.ac.uk/catlink/bib/59131</url>
     <borrowedcount>43</borrowedcount>
     <courses>
        <course>CC100</course>
        <course>CC300</course>
     </courses>
  </item>
  <item id="59176">
     <title>Computer networks : protocols, standards, and interfaces /</title>
     <isbn>0131756052</isbn>
     <url>http://library.hud.ac.uk/catlink/bib/59176</url>
     <borrowedcount>10</borrowedcount>
     <courses>
        <course>CC100</course>
     </courses>
  </item>
  </bookcollection>
like image 214
Dan Davies Avatar asked Sep 10 '26 02:09

Dan Davies


1 Answers

I think you are looking for:

//item[descendant::course/text() = 'CC300']

Working example: http://chris.photobooks.com/xml/default.htm?state=CF

like image 131
Kobi Avatar answered Sep 12 '26 15:09

Kobi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!