Re: [xmljs-users] Parser error: expected document node...
Brought to you by:
djoham,
witchhunter
From: Tornick, E. x. -N. <Edw...@es...> - 2006-08-24 13:33:07
|
I am using a javascript package called prototype.js on the client to do an ajax call to a servlet. The response ends up in a variable in a javascript function on the client. var xmlResponse =3D originalRequest.responseText; When I look at the response it looks like this... <?xml version=3D"1.0"?> <vendor> <name> harry </name> <address> 100 Cherry Tree Lane </address>=09 </vendor> xmlResponse is being processed by xmldos.js =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D var objDom =3D new XMLDoc(xmlResponse, xmlError); var objDomTree =3D objDom.docNode; var tag1Elements =3D objDomTree.getElements("name"); var element =3D tag1Elements[0]; var name =3D element.getText(); =20 var tag1Elements =3D objDomTree.getElements("address"); var element =3D tag1Elements[0]; var address =3D element.getText(); =20 alert(name); alert(address);=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D The nodes are being found. And my alerts show "harry" and "100 cherry Tree Lane" but the error Routine xmlError is called as each node is parsed. I will try the other parser as you suggested if I don't get anywhere with this.=20 Thanks David Ed -----Original Message----- From: David Joham [mailto:dj...@ya...]=20 Sent: Thursday, August 24, 2006 9:16 AM To: Tornick, Edward x. -ND; xml...@li... Subject: Re: [xmljs-users] Parser error: expected document node... Nothings obviously wrong, but I have a suspicion about your response.setContentType("text/xml"); line. How are you getting the data into xmljs? Is it going to a frame something else? Normally, you just write the XML directly into the web page (escaping characters as necessary) in a textarea or something else. I'm curious if what you're doing might be causing the problem somehow. What happens if you use the w3c parser? Does the same error occur? Can you send the list a minimal sample HTML page that causes this error? If we have that, we can probably dive into it and figure out what's going wrong... David --- "Tornick, Edward x. -ND" <Edw...@es...> wrote: > I am using the domparser.js and I get this error... Error expected=20 > document node found text. >=20 > It is from this code in the xmldom.js.... > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 >=20 > function _XMLDoc_handleNode(current) > { > /* > function: _XMLDoc_handleNode > Author: mi...@id... > Description: > adds a markup element to the document */ > if ((current.nodeType=3D=3D'COMMENT') && (this.topNode!=3Dnull)) { > return this.topNode.addElement(current); > } > else if ((current.nodeType=3D=3D'TEXT') || =20 > (current.nodeType=3D=3D'CDATA')) { > // if the current node is a text node: > // if the stack is empty, and this text node isn't just=20 > whitespace, we have > // a problem (we're not in a document element) > if(this.topNode=3D=3Dnull) { > if (trim(current.content,true,false)=3D=3D"") { > return true; > } > else { > return this.error("expected document node, found: " +=20 > current); > } > } > else { > // otherwise, append this as child to the element at the=20 > top of the stack > return this.topNode.addElement(current); > } > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D The values are being parsed correctly but the error is showing = up: > My server side code that generates the xml looks like this.... >=20 > response.setContentType("text/xml"); > PrintWriter out =3D response.getWriter(); > out.println("<?xml version=3D\"1.0\"?>"); > out.println("<vendor>"); > out.println("<name>"); > out.println("harry");=20 > out.println("</name>");=09 > out.println("<address>"); > out.println("100 Cherry Tree Lane"); > out.println("</address>");=09 > out.println("</vendor>"); >=20 > Is anything obviously wrong with this???? >=20 > Thanks, > Ed >=20 > > -------------------------------------------------------------------- > > ----- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier Download IBM WebSphere Application Server v.1.0.1 based on=20 > Apache Geronimo=20 > = http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 1216 > 42> _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users >=20 |