0

I have some gml that looks like this:

<gml:featureMember>
    <a:location>ABCD</a:location>
    <a:ElevatedPoint>
        <gml:pos>44.0 1.2</gml:pos>
        <a:elevation uom="FT">23</a:elevation>
    </a:ElevatedPoint>
</gml:featureMember>
<gml:featureMember>
    <a:location>EFJH</a:location>
    <a:ElevatedPoint>
        <gml:pos>33.3 -6.9</gml:pos>
        <a:elevation uom="FT">244</a:elevation>
    </a:ElevatedPoint>
</gml:featureMember>

I want to get the gml:pos based on value of a:location. So for example, I want the position related to location ABCD. I'm guessing using xpath is the way forward but not really sure where to start.

Any help appreciated. Let me know if you need any more information.

UPDATE

This is what I've go so far:

var positions = document.evaluate("/featureMember/location[ABCD]/ElevatedPoint/pos", xml, null, XPathResult.ANY_TYPE, null);
4
  • Without namespace problem the Xpath should be /featureMember/location[.="ABCD"]/following-sibling::ElevatedPoint/pos Commented Jul 19, 2016 at 14:12
  • Or /featureMember[location[.="ABCD"]]/ElevatedPoint/pos Commented Jul 19, 2016 at 14:13
  • Thanks. Any idea on namespacing? Commented Jul 19, 2016 at 14:29
  • I can't to work with xml in js :( Commented Jul 19, 2016 at 14:36

1 Answer 1

0

Never used Xpath on gml, but this is what i'd do:

/featureMember/location[desired_value]/ElevatedPoint/pos

keep in mind that this is XML xpath syntax and i have no idea how it has to look for GML, and that this will return ALL positions of nodes with the correct location.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried this but I think the namespacing is a problem. I've update above to show what I've got so far.
stackoverflow.com/a/8181480/2102710 Try that, it's a workaround for namespacing...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.