I have an xml like below I am trying to parse using jquery and get something like i wrote below java script to parse it.I have tried below code but i am able to get location not in below format as i expect.
Expected Result:
S1:E1:https://location1
S2:E2:https://location1
xml:
<Country>
<State>
<id>S1</id>
<City>
<E1>
<location>https://location1</location>
</E1>
</City>
<County>
<E2>
<location>https://location2</location>
</E2>
</County>
</State>
<State>
<id>S2</id>
<City>
<E1>
<location>https://location3</location>
</E1>
</City>
<County>
<E2>
<location>https://location4</location>
</E2>
</County>
</State>
</Country>
code
var container = $( document.body );
var xml = '<Country> <State> <id>S1</id> <City> <E1> <location>https://location1</location> </E1> </City> <County> <E2> <location>https://location2</location> </E2> </County> </State> <State> <id>S2</id> <City> <E1> <location>https://location3</location> </E1> </City> <County> <E2> <location>https://location4</location> </E2> </County> </State> </Country>',
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
$location = $xml.find( 'location' );
container.append( $("<p/>", { "text" : $location.text() }) );