Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

1 reply to this topic
#1
Posted 16 February 2012 - 04:56 PM
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
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
"Programming is like **. 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
Also tagged with one or more of these keywords: xml
Language Forums →
Java →
[JAXB API] XmlElementWrapper - No items in the ArrayStarted by Crusher, 11 Nov 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
How to solve - Node no longer existStarted by anjshr7, 21 Jul 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
Fatal error: Call to undefined method SimpleXMLElement::attribute()Started by anjshr7, 20 Jul 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
parent html content included in xml outputStarted by yonghan79, 30 May 2015 ![]() |
|
![]() |
||
Language Forums →
PHP →
To get the data in the xml in the url ( shown below) and then print the rates it to the screen and copy it to the mongodb colle...Started by ShebeerAhammed, 14 Apr 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download