Tony Vitabile
Tony Vitabile

Reputation: 8594

XPath to retrieve an attribute of the n-th child element of its parent

I have the following XML:

<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>

I need an XPath to retrieve the value of the IsInUse attribute of the n-th Satellite tag.

I've been using this XPath: a:Satellites/a:Satellite[1]@IsInUse

But it doesn't work.

Tony

Upvotes: 0

Views: 98

Answers (1)

choroba
choroba

Reputation: 241918

A slash is missing in your XPath:

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

Upvotes: 1

Related Questions