Xml question

I call the following code when a value in a field changes. Based on the value in the field I lookup the value in the xmldoc and load a bunch of other fields. Does anyone know why this does not work if I uncomment the msgbox statement??? Is it a timing issue? Also I would prefer to load this document when the user opens the document but have been unable to find a way to do this. I have done this on an ASP website so I know it is possible, just unsure on how to go forward in domino. Any help is appreciated.

sub checkatlas()

xmlqry = “http://ntsta1w/develop/Muni.NSF/6D58DF43A6EA82B186256E4A006C9EC0?readviewentries&restricttocategory=” & document.forms(0).atlas.value

'msgbox(xmlqry)

Set xmlDoc = CreateObject(“Microsoft.XMLDOM”)

xmlDoc.async = true

xmlDoc.load xmlqry

'Code only works if I leave this msgbox in

msgbox(“root”)

Set root1 = xmlDoc.documentElement

	set onodelist= root1.childNodes

	count = 0 

	for each xNode in onodelist

		if xnode.nodename = "viewentry" then

		set childnode = xnode.firstchild

		msgbox(childnode.text)

		end if

	next

end sub

Subject: xml question -figured it out

Load the xml doc by putting it in between the script tags without a function or sub