Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript XML
hi all
i have a URL displays XML data, and i want to take or read this data from this file and save it into data table or list using javascript.
i mean that all i want is how to read from XML file and save data into data table.
 
thanks
Posted 17-Nov-12 21:04pm
Comments
@AmitGajjar at 18-Nov-12 3:11am
   
do you mean by database table ?
NNos2012 at 18-Nov-12 3:16am
   
no , i want a way to read from XMl and display data in my page so, i need to make that a list or data table to store data first in it then display it.
@AmitGajjar at 19-Nov-12 1:43am
   
See my solution.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
If you need to render your data in the html page form the javascript then why should you read the data through javascript and display ? you can use XSLT to transform your xml data into your desired design in html page.
 
Please refer http://www.w3schools.com/xsl/[^] link to know more about XSLT.
 
Let me know if helps you. Also see the example given in the above link
 
thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
NNos2012 at 18-Nov-12 4:17am
   
thanks alot for your help, but what about reading XML from URl
i mean that my XML data appears on html page like this




abc
xyz
pqr


123
456



and i don't want user to see it like this . i want to read it first and display it as i want and as you said before

thanks
@AmitGajjar at 19-Nov-12 1:44am
   
yes, in that case XSLT helps you. you need to study it well.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Does this help ?
xmlhttp.open("GET", "employee.XML", false);
 xmlhttp.send(null); 
if (xmlhttp.status==200) 
{ xmlDoc = xmlhttp.responseXML; 
var empid= xmlDoc.getElementsByTagName("emp"); 
var total = placeMarks.length; 
var names = xmlDoc.getElementsByTagName("Name");
 var designation= xmlDoc.getElementsByTagName("designation"); 
var phone= xmlDoc.getElementsByTagName("phone"); ..... ; } 
else 
if (xmlhttp.status==404) { alert("XML could not be found"); 
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Or you can use Jquery
 
$.get(url,function(data){
 xmlDoc = data; 
var empid= xmlDoc.getElementsByTagName("emp"); 
var total = placeMarks.length; 
var names = xmlDoc.getElementsByTagName("Name");
 var designation= xmlDoc.getElementsByTagName("designation");
 var phone= xmlDoc.getElementsByTagName("phone"); });
  Permalink  
Comments
Nelek at 18-Nov-12 5:29am
   
Please don't post solutions to add information, to ask something or to comment another user.
- To add information to your message, you can use the widget "Improve question" / "Improve solution" at the bottom of your text.
- To ask/answer a user, you can use the widget "Have a question or comment?" (as I am doing right now with you) or the widget "reply" in another comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 402
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,404
2 Maciej Los 3,474
3 Peter Leow 3,299
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 18 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100