gpt4 book ai didi

xml - XPATH帮助选择元素

转载 作者:行者123 更新时间:2023-12-03 16:59:36 26 4
gpt4 key购买 nike

所以我有这个XML数据库

<uni>
<!-- SUBJECTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<subjects>
<subject code="XYZ111">
<title>Java for 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 and 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 for 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 for car dealers</title>
<credits>6</credits>
</subject>
<subject code="XYZ101">
<title>Programming for 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 really 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>


而且我正在尝试寻找包括抽象代数实验室在内的学科名称。到目前为止,这是我能想到的最好的答案,但找不到匹配项:/ //uni/subjects/subject/laboratories/laboratory/topics/topic[text()="abstract algebra"]

最佳答案

您可以这样尝试:

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

关于xml - XPATH帮助选择元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30260184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com