以下是 XML 文件 -
<Chapters>
<Chapter>
<Name>Introduction</Name>
<Heads>
<Head>
<No>1</No>
<Title>History of Internet</Title>
<Desc>
..............
</Desc>
</Head>
<Head>
<No>2</No>
<Title>History of HTML</Title>
<Desc>
..............
</Desc>
</Head>
</Heads>
</Chapter>
<Chapter>
<Name>Learn HTML</Name>
<Heads>
<Head>
<No>1</No>
<Title>Browsers</Title>
<Desc>
..............
</Desc>
</Head>
<Head>
<No>2</No>
<Title>Browser War</Title>
<Desc>
..............
</Desc>
</Head>
<Head>
<No>3</No>
<Title>HTML, DHTML</Title>
<Desc>
..............
</Desc>
</Head>
</Heads>
</Chapter>
</Chapters>
我想列出 Chapters/Chapter/Name=Introduction 和 Chapters/Chapter/Heads/Head/No=1 以下是我在 baseX 中执行的查询 -
/Chapters/Chapter[contains(Name,'Introduction') and contains(Heads/Head/No,'1')]/Heads/Head/Title
这就是错误 -
Query: Chapters/Chapter[contains(Name,'Introduction') and contains(Heads/Head/No,'1')]/Heads/Head/Title
Error: [XPTY0004] Single item expected, (element No { ... }, element No { ... }) found.
根据 baseX 网站,错误 XPTY0004 的描述是 -
This error is raised if an expression has the wrong type, or cannot be cast into the specified type. It may be raised both statically (during query compilation) or dynamically (at runtime).
我做错了什么??