2015-10-18 71 views
1

我的XML看起来像下面那样。我想在// book // genre/text()='classic'时检查'number'的值,我想返回1000和1003.任何人都可以帮忙吗?XPATH用于根据另一个元素的值检查xml元素的值

<list> 
<book> 
    <author> 
     <name>John</name> 
     <number>1000</number> 
    </author> 
    <otherDetails> 
     <genre>classic</genre> 
     <price>$50</price> 
    </otherDetails> 
    <title>Dusk</title> 
    <isbn>dsdaassda</isbn> 
</book> 
<book> 
    <author> 
     <name>MARK</name> 
     <number>1001</number> 
    </author> 
    <otherDetails> 
     <genre>comedy</genre> 
     <price>$140</price> 
    </otherDetails> 
    <title>Midnight</title> 
    <isbn>dsdaassda</isbn> 
</book> 
<book> 
    <author> 
     <name>Pete</name> 
     <number>1003</number> 
    </author> 
    <otherDetails> 
     <genre>classic</genre> 
     <price>$140</price> 
    </otherDetails> 
    <title>Morning</title> 
    <isbn>EFGH</isbn> 
</book> 

回答

4

+0

@vpk它。请注意,节点和属性名称和值区分大小写 –

+0

是的。谢谢 ! – Chris

相关问题