用于选择节点和条件的xpath查询

时间:2013-02-04 10:51:13

标签: c# xml xpath

<?xml version="1.0"?>  
<AppXmlLogWritter>  
  <LogData>  
    <LogID>235820130202134128634953894887814709273</LogID>  
    <LogDateTime>20130202134128</LogDateTime>  
    <LogType>Warning</LogType>  
    <LogFlag>PACSFlag</LogFlag>  
    <LogApplication>PACSLogApplication</LogApplication>  
    <LogModule>PACSLogModule</LogModule>  
    <LogLocation>PACSLogLocation</LogLocation>  
    <LogText>PACSLogText</LogText>  
  </LogData>  
  <LogData>  
    <LogID>2358201302021341286349538948878147093861</LogID>  
    <LogDateTime>20130202134128</LogDateTime>  
    <LogType>Error</LogType>  
    <LogFlag>PACSFlag</LogFlag>  
    <LogApplication>PACSLogApplication</LogApplication>  
    <LogModule>PACSLogModule</LogModule>  
    <LogLocation>PACSLogLocation</LogLocation>  
    <LogText>PACSLogText</LogText>  
  </LogData>      
</AppXmlLogWritter>  

获取具有LogApplication的节点以“P”开头且位置&lt; = 1且&gt; = 2

  

/ AppXmlLogWritter / LogData [LogApplication / text()[starts-with(。,'P')]]和LogData [position()&lt; = 1 and position()&gt; = 2]

我已经写过上面的查询但是失败了

1 个答案:

答案 0 :(得分:0)

/AppXmlLogWritter/LogData[starts-with(LogApplication, 'P') and (position()<=1 and position()>=2)]