Xpath的新功能。試圖在SSIS中使用XML任務來加載一些值。使用下面提到的微軟XML庫存。如何在Xpath中使用多個條件?
我該如何在bookstore /書籍中加載風格新穎,獎勵='普利策'的名字? //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>
這是完全正常,沒有什麼提升。 – 2013-04-20 12:38:07
我不會使用'text()',除非我處理的是混合內容(例如,一個XHTML'p'元素包含'
快速狐狸跳過懶狗
'),我明確地需要選擇一個文本孩子或後代(例如,'/ p/text()[1]'用'The'選擇文本節點)。否則,我會簡單地比較元素。因此,在你的案例中,//使用'author/award/text()'就不會獲得任何收益。 – 2013-04-20 12:43:54謝謝Jens和Martin分享你的觀點。 – Akshay 2013-04-20 13:44:39