473,378 Members | 1,119 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

XML DOM in IE using Javascript

I am tryint to view a xml document in Internet Exploer as a ActiveX
object using Javascript but it does not work. I only see the button
but nothing happens when i click it. I am trying to view the
'firstChild' of the xml document.

here is the code;
----------------------------------------------------------------
<html>
<head>
<script language="javascript">
<!--
function alert()
{

var xmldoc, meetingsNode, meetingNode;
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.load("members.xml");
document.write("works so far");

meetingsNode = xmldoc.documentElement;
document.write("works so far");
meetingNode = meetingsNode.firstChild;
//does not process after this line

document.writeln(meetingNode);

}
//-->
</script>

<title>Read Members.xml</title>
</head>

<body>

<input type="button" name="submit" onclick="alert()" />

</body>
</html>
Jul 23 '05 #1
2 2725
On Sat, 23 Apr 2005 14:51:50 -0700, in comp.lang.javascript Kenneth
<ja********@hotmail.com> wrote:
| I am tryint to view a xml document in Internet Exploer as a ActiveX
| object using Javascript but it does not work. I only see the button
| but nothing happens when i click it. I am trying to view the
| 'firstChild' of the xml document.
|
| here is the code;
| ----------------------------------------------------------------
| <html>
| <head>
| <script language="javascript">
| <!--
| function alert()
| {
| var xmldoc, meetingsNode, meetingNode;
| xmldoc = new ActiveXObject("Microsoft.XMLDOM");
| xmldoc.load("members.xml");
| document.write("works so far");
| meetingsNode = xmldoc.documentElement;
| document.write("works so far");
| meetingNode = meetingsNode.firstChild;
| //does not process after this line
| document.writeln(meetingNode);
| }
| //-->
| </script>
|
| <title>Read Members.xml</title>
| </head>
| <body>
| <input type="button" name="submit" onclick="alert()" />
| </body>
| </html>


alert is a predefined javascript function. You might give your
function another name i.e. xalert() and see what happens.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #2


Kenneth wrote:
I am tryint to view a xml document in Internet Exploer as a ActiveX
object using Javascript but it does not work. I only see the button
but nothing happens when i click it. I am trying to view the
'firstChild' of the xml document. var xmldoc, meetingsNode, meetingNode;
xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.load("members.xml");
document.write("works so far");


Loading happens asynchronously by default so you either need an
onreadystatechange handler e.g.

var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument.onreadystatechange = function () {
if (xmlDocument.readyState == 4) {
alert(xmlDocument.xml);
}
};
xmlDocument.load('test2005042301.xml');

or you need to load synchronously

var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
xmlDocument.async = false;
var wellFormed = xmlDocument.load('test2005042301.xml');
if (wellFormed) {
alert(xmlDocument.xml);
}

but inside the browser synchronous loading blocks the user agent so that
you would better use asynchronous loading as described above.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Mel | last post by:
if you know of dynamic expandable folder using CSS and display function, please drop me a note Yours, Mel
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
7
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
by: Jeronimo Bertran | last post by:
A couple of questions I am having problems with converting my JavaScript to C#. I have the following code using JavaScript for the mouseover handler that works fine: <SCRIPT...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
0
AnuSumesh
by: AnuSumesh | last post by:
Hi All, I want to call RDP on Page load and it is working fine.My code is in C#. But I am unable to perform following functions 1. when i disconnected from RDP, i want to go back to...
7
by: JDOMPer | last post by:
Donít misunderstand me Ė I use AJAX, but I think there is a far simpler, elegant alternative that just uses Javascript, the DOM and Php ( hence - JDOMP) for data transfers, and is cross-browser...
6
Frinavale
by: Frinavale | last post by:
Apparently I have a lot of questions today regarding JavaScript security. I've implemented a JavaScript Object that intercepts page submits (postbacks) and then displays a UI prompting the user...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.