DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    mehra Guest

    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.






  2. #2
    David Tjandra Guest

    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();




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links