Link to home
Start Free TrialLog in
Avatar of chrismarx
chrismarxFlag for United States of America

asked on

Parsing Xml With jQuery without Using XPath

i need to upgrade to the latest jQuery version, and the Xpath extension did not work for me. I have not found any good new resources about code for parsing xml, the xml example is in the code window-

as you can see, each placemark can contain different types of tags, so
i need to just be able to access the coordinates by giving different
paths like:

for (var j=0; j<placemarks.length/3; j++) {
      var coords = $('Document/Folder:eq('+1+')/Placemark:eq('+j+')/
LineString/coordinates', xml).text();
etc...

is there any good way to do this?

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
        <Document>
                <Folder>
                        <name>Final_Label_geom</name>
                        <open>1</open>
                        <Placemark>
                                <Style>
                                        <IconStyle>
                                                <color>ffc0c0c0</color>
                                        </IconStyle>
                                </Style>
                                <Point>
                                        <extrude>1</extrude>
<coordinates>-77.988788,30.779793,0.000000 </coordinates>
                                </Point>
                        </Placemark>
                <Placemark>
                                <Style>
                                        <LineStyle>
                                                <color>ff000000</color>
                                                <width>1</width>
                                        </LineStyle>
                                </Style>
                                <LineString>
                                        <tessellate>1</tessellate>
                                        <extrude>1</extrude>
                                        <coordinates>-96.621063,33.166782,0.000000
-101.993915,34.013136,0.000000 </coordinates>
                                </LineString>
                        </Placemark>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chrismarx
chrismarx
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator