queeeenegypt
New Member
JavaScript:I used the following code on FireFox to read XML file contents:HTML:\[code\]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>javascript ?? xml??</title> <script type="text/javascript" src="http://stackoverflow.com/questions/14614211/readXML.js"></script> </head> <body> </body> </html> \[/code\]The javascript:\[code\]readMyXML={ init: function(){ readMyXML.javaScriptReadXML(); }, javaScriptReadXML: function(){ var xmlDoc =document.implementation.createDocument("", "", null); //xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0"); xmlDoc.async= false; xmlDoc.load('PAS1.xml'); /* load XML file */ //xmlDoc.load('myxml.xml'); var objNodeList = xmlDoc.getElementsByTagName("Slide"); var Node=objNodeList.item(0); var mytext=Node.getElementsByTagName("Context"); alert("length="+mytext.item(0).Language); } }window.addEventListener('load', readMyXML.init,false);\[/code\]But no matter I tried to get any content of the XML, it juse show undefined in the alert.How to solve this problem.The XML is something like this:\[code\]<?xml version="1.0" encoding="utf-8"?><Survey SurveyID="PAS1" Description="PAS first part"><Slide SlideID="S-N1"><Question><Context Language="English">We would like you to fill out a questionnaire </Context></Question><Input Optional="true"><Nothing ChoiceID="1" /></Input><Next /></Slide>\[/code\]