C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Reading XML Data from JavaScript


Posted Date: 30 Oct 2009    Resource Type: Code Snippets    Category: Javascript
Author: PraveenMember Level: Diamond    
Rating: 1 out of 5Points: 4



hi,

A Small Article Which Reads Data from XML File using JavaScript!


<--html>
<--body>
<--html>
<--body>
<--script type="text/javascript">
var xmlDoc;
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load("xmlFile2.xml");

var x=xmlDoc.documentElement.childNodes;

for (var i=0;i{
if (x[i].nodeType==1)
{
//Process only element (nodeType 1) nodes
document.write(x[i].nodeName + ": ");
document.write(x[i].childNodes[0].nodeValue);
document.write("
");
}
}
<--/script>
<--/body>
<--/html>








and your XML File look like this


<--?xml version="1.0" encoding="utf-8" ?>
<--Sample>
<--From>Praveen
<--for>Dot Net Spider
<--purpose>Reading Xml File from java script
<--/Sample>



copy above html code and paste that in a note pad and save that in your desktop with filename.html. Create xml file with XmlFile2 name and save that in your desktop.

Run the HTML Code now you can able to see the xml document data!

hope this will help some one

Attachments

  • ReadingXMLDatafromJavaScript (34497-3066-XMLReader.zip)


  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    Read xml file javascript  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Simple menu control
    Previous Resource: Creating File upload Controls using Java Script
    Return to Discussion Resource Index
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use