Hello,
I didn't use XML files for a very long time and I have forgot how to interact with complicate files. Need to retrieve the value of an Element in an XML file that is sitting too deep in that. For example:
I want to retrieve the latitude value that appears here: DirectionsResponse/route/leg/step/start_location/lat. Need to do the same for Longitude and latitude/Longitude for the end_location. "leg" contains more elements but I want just "step". Also, "step" elements are not always the same quantity, so need to check the size of the "leg" or how many "step" contains. I made some tries but all have failed! Please anybody knows how my for loop should be in order to getting correctly all "start_location" and "end_location" from all "step"?
Thanks in advance,
toto_7
1 reply to this topic
#1
Posted 16 February 2012 - 04:56 PM
"Programming is like sex. One mistake and you have to support it for the rest of your life."
-Michael Sinz|
|
|
#2
Posted 11 April 2012 - 05:12 AM
Here you have some good old sample code :
it works with the xmlDoc object in windows, understanding you are working in ASP.NET / ajax
you can always parse it with RegExp :
here is a reference :
http://www.regular-e...iptexample.html
txt="<bookstore><book>";
txt=txt+"<title>The life of the javascript coder</title>";
txt=txt+"<author>Giada De Laurentiis</author>";
txt=txt+"<year>2008</year>";
txt=txt+"</book></bookstore>";
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(txt,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.loadXML(txt);
}
it works with the xmlDoc object in windows, understanding you are working in ASP.NET / ajax
you can always parse it with RegExp :
here is a reference :
http://www.regular-e...iptexample.html
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









