newbie: having problem even with my first xml script
dear friends,
just started a book "Teach yourself xml in 24 hours".
The first example is not working.
it goes like this
in the first chapter there is one simple xml file>>
<?xml version="1.0"?>
<MESSAGE>
<TO>STUDENT</TO>
<FROM>AUTHOR</FROM>
<SUBJECT>INTRODUCTION TO XML</SUBJECT>
<BODY>WELCOME TO XML!</BODY>
</MESSAGE>
then contents of this file called from a html file>>>
<html>
<head>
<script language=javaScript>
var RootElement1;
var xmlDoc1=new ActiveXObject("microsoft.xmldom");
xmlDoc1.load("listing.xml");
function StartUp()
{
if (xmlDoc1.readyState="4")
{
StartLoading();
}
else
{
alert("Loading operation could not start");
}
}
function StartLoading()
{
RootElement1=xmlDoc1.documentElement;
todata.innerText = RootElement1.childNodes(0).text;
fromdata.innerText = RootElement1.childNodes(1).text;
subjectdata.innerText = RootElement1.childNodes(2).text;
bodydata.innerText = RootElement1.childNodes(3).text;
}
</script>
</head>
<body bgcolor="ffffff" onLoad = "StartUp()">
TO: <span id=todata></span><br>
FROM: <span id=fromdata></span><br>
SUBJECT: <span id=subjectdata></span><br>
BODY: <span id=bodydata></span><br>
</ body>
</html>
Can anyone tell me why it is not working, and where i am going wrong.
thank you very much in advance.
Re: newbie: having problem even with my first xml script
Dear Mehra,
The statement "if (xmlDoc1.readyState="4")" is wrong.
It should be: "if (xmlDoc1.readyState=="4")"
Hope that helps,
David Tjandra
"mehra" <mehra@hotvoice.com> wrote in message
news:3dae9031$1@tnews.web.devx.com...
> function StartUp()
> {
> if (xmlDoc1.readyState="4")
> {
> StartLoading();