xml - XPATH help selecting elements -


so have xml database

<uni> <!-- subjects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->    <subjects>     <subject code="xyz111">       <title>java housewives</title>       <credits>6</credits>       <laboratories>           <laboratory num="lab1">             <date>12-mar-2009</date>             <topics>                <topic>variables</topic>                <topic>constants</topic>             </topics>             <description>declarations of variables , constants</description>         </laboratory>           <laboratory num="lab2">             <date>12-apr-2009</date>             <topics>                <topic>expressions</topic>             </topics>             <description>types of expressions</description>         </laboratory>           <laboratory num="lab3">             <date>12-may-2009</date>             <topics>                <topic>conditionals</topic>                <topic>loops</topic>             </topics>             <description>control statements</description>         </laboratory>       </laboratories>     </subject>     <subject code="xyz235">       <title>database systems politicians</title>       <credits>6</credits>       <laboratories>         <laboratory num="lab1">             <date>10-jan-2001</date>             <topics>                <topic>classes</topic>                <topic>associations</topic>                <topic>properties</topic>               </topics>               <description>conceptual modeling</description>         </laboratory>         <laboratory num="lab2">             <date>10-jan-2002</date>             <topics>                <topic>relational tables</topic>                <topic>primary keys</topic>                <topic>foreign keys</topic>               </topics>               <description>relational data model</description>         </laboratory>        </laboratories>     </subject>     <subject code="xyz987">       <title>ethics car dealers</title>       <credits>6</credits>     </subject>     <subject code="xyz101">       <title>programming mathematicians</title>       <credits>6000</credits>       <laboratories>         <laboratory num="lab1">             <date>10-jan-2002</date>             <topics>                <topic>abstract algebra</topic>                 </topics>             <description>hilbert spaces of programming languages</description>         </laboratory>         <laboratory num="lab2">             <date>13-may-2002</date>             <topics>                <topic>topology</topic>                 </topics>             <description>theory of homothopy</description>         </laboratory>        </laboratories>     </subject>         <subject code="zzz777">        <title>cooking</title>        <credits>5</credits>        <laboratories/>         </subject>     <subject code="zzz778">       <title>dancing</title>       <credits>5</credits>       <laboratories/>        </subject>        <subject code="abc123">       <title>general theory of everything</title>       <credits>4</credits>       <laboratories>         <laboratory num="lab1">             <date>20-jan-2012</date>             <topics>                <topic>space</topic>                 </topics>             <description>nothing interesting</description>         </laboratory>           </laboratories>        </subject>    </subjects> <!--  enrolments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->       <enrolments>       <enrolment snum="d2345" code="abc123">         <date>12-dec-2011</date>         <status>dropped</status>         <time>20</time>         <ip>16.23.234.002</ip>         <lab-enrolments>           <laboratory num="lab1"/>         </lab-enrolments>       </enrolment>       <enrolment snum="d2346" code="abc123">         <date>12-dec-2011</date>         <status>dropped</status>         <time>2</time>         <ip>16.23.234.003</ip>         <lab-enrolments>           <laboratory num="lab1"/>         </lab-enrolments>       </enrolment>       <enrolment snum="d2347" code="abc123">         <date>12-dec-2011</date>         <status>dropped</status>         <time>10</time>         <ip>16.23.234.003</ip>       </enrolment>       <enrolment snum="d2348" code="abc123">         <date>12-dec-2011</date>         <status>dropped</status>         <time>20</time>         <ip>16.23.234.025</ip>       </enrolment>       <enrolment snum="d6767" code="abc123">         <date>13-dec-2011</date>         <status>valid</status>         <time>5</time>         <ip>16.23.234.202</ip>       </enrolment>       <enrolment snum="d2345" code="zzz778">         <date>14-dec-2007</date>         <status>valid</status>         <time>10</time>         <ip>16.23.234.402</ip>       </enrolment>       <enrolment snum="d6767" code="zzz777">         <date>12-sep-2005</date>         <status>valid</status>         <time>15</time>         <ip>16.23.234.202</ip>       </enrolment>       <enrolment snum="d2330" code="xyz101">         <date>01-jan-2002</date>         <status>valid</status>         <time>3</time>         <ip>16.23.234.203</ip>         <lab-enrolments>           <laboratory num="lab1"/>           <laboratory num="lab2"/>         </lab-enrolments>        </enrolment>       <enrolment snum="d2349" code="xyz101">         <date>01-jan-2002</date>         <status>valid</status>         <time>7</time>         <ip>16.23.234.202</ip>         <lab-enrolments>           <laboratory num="lab1"/>           <laboratory num="lab2"/>         </lab-enrolments>       </enrolment>       <enrolment snum="d2341" code="xyz101">         <date>01-jan-2002</date>         <status>valid</status>         <time>6</time>         <ip>16.23.234.201</ip>         <lab-enrolments>           <laboratory num="lab1"/>         </lab-enrolments>       </enrolment>       <enrolment snum="d6767" code="xyz101">         <date>01-jan-2002</date>         <status>provisional</status>         <time>5</time>         <ip>16.23.234.002</ip>       </enrolment>       <enrolment snum="d6767" code="xyz235">         <date>31-dec-2000</date>         <status>provisional</status>         <time>30</time>         <ip>16.23.234.602</ip>       </enrolment>       </enrolments> </uni> 

and i'm trying find titles of subjects include laboratories on abstract algebra. far best answer come with, doesn't find match :/ //uni/subjects/subject/laboratories/laboratory/topics/topic[text()="abstract algebra"]

you can try way :

//subject[laboratories/laboratory/topics/topic="abstract algebra"]/title 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -