如何在Xpath中使用多个条件?

Aks*_*hay 6 xpath

Xpath新手.试图在SSIS中使用XML任务来加载一些值.使用下面提到的Microsoft的XML库存.

如何在书店/书籍中加载名字价值的新颖和奖励='普利策'? //book[@style='novel' and ./author/award/text()='Pulitzer']是我在想的.它给出了整个元素.我应该在哪里修改才能获得名字值?

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
  <book style="autobiography">
    <author>
      <first-name>Joe</first-name>
      <last-name>Bob</last-name>
      <award>Trenton Literary Review Honorable Mention</award>
    </author>
    <price>12</price>
  </book>
  <book style="textbook">
    <author>
      <first-name>Mary</first-name>
      <last-name>Bob</last-name>
      <publication>Selected Short Stories of
        <first-name>Mary</first-name>
        <last-name>Bob</last-name>
      </publication>
    </author>
    <editor>
      <first-name>Britney</first-name>
      <last-name>Bob</last-name>
    </editor>
    <price>55</price>
  </book>
  <magazine style="glossy" frequency="monthly">
    <price>2.50</price>
    <subscription price="24" per="year"/>
  </magazine>
  <book style="novel" id="myfave">
    <author>
      <first-name>Toni</first-name>
      <last-name>Bob</last-name>
      <degree from="Trenton U">B.A.</degree>
      <degree from="Harvard">Ph.D.</degree>
      <award>P</award>
      <publication>Still in Trenton</publication>
      <publication>Trenton Forever</publication>
    </author>
    <price intl="Canada" exchange="0.7">6.50</price>
    <excerpt>
      <p>It was a dark and stormy night.</p>
      <p>But then all nights in Trenton seem dark and
      stormy to someone who has gone through what
      <emph>I</emph> have.</p>
      <definition-list>
        <term>Trenton</term>
        <definition>misery</definition>
      </definition-list>
    </excerpt>
  </book>
  <my:book xmlns:my="uri:mynamespace" style="leather" price="29.50">
    <my:title>Who's Who in Trenton</my:title>
    <my:author>Robert Bob</my:author>
  </my:book>
</bookstore>
Run Code Online (Sandbox Code Playgroud)

Aks*_*hay 8

我得到了答案.

//book[@style='novel' and ./author/award/text()='Pulitzer']//first-name
Run Code Online (Sandbox Code Playgroud)


Dim*_*hev 5

用途:

/*/book[@style='novel']/author[award = 'Pulitzer']/first-name
Run Code Online (Sandbox Code Playgroud)

这将选择任何first-name其元素author的父具有award与"普利策"的字符串值子和其(所述的author亲本)是一个bookstyle属性具有值"小说"且父是XML文档的顶部元件.