Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 26th, 2003, 07:37 PM
Registered User
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Loop in XML DOM?

Wondering if anyone can help me include a loop into my xml using dom. Whenever I try to launch this page the system crashes.

        <title>BQI DOM Example</title>
        <script language="JavaScript">

function getActiveClasses()

xmlDocumentObject = new ActiveXObject ("Microsoft.XMLDOM")

var bqiclassesNode, classNode, courseNode, statusNode, displayText

bqiclassesNode = xmlDocumentObject.documentElement
classNode = bqiclassesNode.firstChild
courseNode = classNode.firstChild.nextSibling.nextSibling.text
statusNode = classNode.lastChild.text

for (var i = 0; statusNode = '1'; i++)

displayText = "Active Classes: " + courseNode + " - " + "Status: " + statusNode
displayDIV.innerHTML = displayText
        <input type="button" value="Display Active Classes" onclick="getActiveClasses()">
            <br />
            <div id="displayDIV"/>
Old November 27th, 2003, 01:46 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 147
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to armmarti

You have an infinite loop there. Instead, use this construct:
for(var i = 0; i < theNode.childNodes.length; ++i) {
  currentChild = theNode.childNodes[i];
Old November 27th, 2003, 04:40 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

And also...
"Microsoft.XmlDom" is severely deprecated as you don't know what dom class you'll get. If you can control the environment you use install version 4.0 sp2 from msdn and use "Msxml2.DomDocument.4.0" or failing that most machines will have version 3, "Msxml2.DomDocument.3.0".
If you use "Microsoft.XmlDom" you could get the pre XPath parser, it only supports XSLPattern which has a different syntax entirely for searches.


Old November 27th, 2003, 09:16 AM
Registered User
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Armen, Thanks Joe! I am new to xml and only a novice with JavaScript so I appreciate your tips. I kept thinking about this all night and I wondered if I had an infinite loop. Again, thank you VERY MUCH!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing xml using DOM balarkavelidi XML 1 January 31st, 2006 10:28 PM
XML DOM / ASP 3.0 xica XML 1 July 13th, 2004 12:23 AM
Compressed XML in DOM Sam_saha XML 2 April 11th, 2004 06:18 PM
XML DOM with JScript --- PLEASE HELP!!! bebe XML 4 October 1st, 2003 11:40 AM
XML DOM and Javascript lilu XML 3 September 25th, 2003 07:55 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.