2012-07-25 59 views
0

我有下面的XML:XPath來檢索其母公司的第n個子元素的屬性

<ModuleInfo xsi:type="NMEAGPSInfo" name="NMEAGPS" id="f77f721c-8287-4609-80d4-4458011219ff"> 
    . . . 
    <Satellites Number="3" Quality="2"> 
     <Satellite IsInUse="true"> 
      <Code>28</Code> 
      <SignalToNoiseRatio>22</SignalToNoiseRatio> 
      <Elevation>18</Elevation> 
      <Azimuth>285</Azimuth> 
     </Satellite> 
     <Satellite IsInUse="true"> 
      <Code>08</Code> 
      <SignalToNoiseRatio>20</SignalToNoiseRatio> 
      <Elevation>46</Elevation> 
      <Azimuth>312</Azimuth> 
     </Satellite> 
     . . . 
    </Satellites> 
    . . . 
</ModuleInfo> 

我需要一個XPath檢索第n個衛星標籤的IsInUse屬性的值。

我一直在使用這個XPath:一:衛星/一:衛星[1] @IsInUse

但它不工作。

託尼

回答

1

的斜線缺少你的XPath:

a:Satellites/a:Satellite[1]/@IsInUse