Re: [xmljs-users] Parser error: expected document node...
Brought to you by:
djoham,
witchhunter
From: David J. <dj...@ya...> - 2006-08-26 02:03:54
|
Hi Ed,=0A=0AI can't reproduce this with the file I'm attaching which I thin= k recreates your environment as close as I can without your ajax client. T= he only thing I can think of is that maybe your servlet is sending a differ= ent character encoding with the XML than your page is loaded with and the t= ext nodes are getting confused somehow...=0A=0ADid you have any better luck= with the W3C DOM Parser?=0A=0ABest regards,=0A=0ADavid=0A=0A=0A----- Origi= nal Message ----=0AFrom: "Tornick, Edward x. -ND" <Edward.x.Tornick.-ND@esp= n.com>=0ATo: David Joham <dj...@ya...>; xml...@li...urceforge.= net=0ASent: Thursday, August 24, 2006 7:32:08 AM=0ASubject: RE: [xmljs-user= s] Parser error: expected document node...=0A=0AI am using a javascript pac= kage called prototype.js on the client to do=0Aan ajax call to a servlet.= =0AThe response ends up in a variable in a javascript function on the=0Acli= ent.=0A=0A var xmlResponse =3D originalRequest.responseText;=0A=0AWhen I lo= ok at the response it looks like this...=0A=0A <?xml version=3D"1.0"?>= =0A <vendor>=0A <name>=0A harry=0A </name>= =0A <address>=0A 100 Cherry Tree Lane=0A </addres= s> =0A </vendor>=0A=0AxmlResponse is being processed by xmldos.js= =0A=0A=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=0A var objDom =3D new XMLDoc(xmlResponse, xmlErro= r);=0A var objDomTree =3D objDom.docNode;=0A var tag1Elements =3D objDomT= ree.getElements("name");=0A var element =3D tag1Elements[0];=0A var name = =3D element.getText();=0A =0A var tag1Elements =3D objDomTree.getElements= ("address");=0A var element =3D tag1Elements[0];=0A var address =3D eleme= nt.getText();=0A =0A alert(name);=0A alert(address); =0A=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=0A=0AThe nodes are being found. And my alerts show "harry" and "1= 00 cherry=0ATree Lane" but the error=0ARoutine xmlError is called as each = node is parsed.=0A=0AI will try the other parser as you suggested if I don'= t get anywhere=0Awith this. =0A=0AThanks David=0A=0AEd=0A=0A-----Original M= essage-----=0AFrom: David Joham [mailto:dj...@ya...] =0ASent: Thursday= , August 24, 2006 9:16 AM=0ATo: Tornick, Edward x. -ND; xmljs-users@lists.s= ourceforge.net=0ASubject: Re: [xmljs-users] Parser error: expected document= node...=0A=0A=0ANothings obviously wrong, but I have a suspicion about you= r=0Aresponse.setContentType("text/xml");=0Aline. How are you getting the da= ta into xmljs? Is it going to a frame=0Asomething else? Normally, you just = write the XML directly into the web=0Apage (escaping characters as necessar= y) in a textarea or something else.=0AI'm curious if what you're doing migh= t be causing the problem somehow.=0A=0AWhat happens if you use the w3c pars= er? Does the same error occur?=0A=0ACan you send the list a minimal sample = HTML page that causes this error?=0AIf we have that, we can probably dive i= nto it and figure out what's=0Agoing wrong...=0A=0ADavid=0A=0A--- "Tornick,= Edward x. -ND" <Edw...@es...> wrote:=0A=0A> I am using th= e domparser.js and I get this error... Error expected =0A> document node fo= und text.=0A> =0A> It is from this code in the xmldom.js....=0A> =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=0A> =0A> =0A> function = _XMLDoc_handleNode(current)=0A> {=0A> /*=0A> function: _XMLDoc_handle= Node=0A> Author: mi...@id...=0A> Description:=0A> adds a = markup element to the document */=0A> if ((current.nodeType=3D=3D'COMME= NT') && (this.topNode!=3Dnull)) {=0A> return this.topNode.addElemen= t(current);=0A> }=0A> else if ((current.nodeType=3D=3D'TEXT') || = =0A> (current.nodeType=3D=3D'CDATA')) {=0A> // if the current node = is a text node:=0A> // if the stack is empty, and this text node is= n't just =0A> whitespace, we have=0A> // a problem (we're not in a = document element)=0A> if(this.topNode=3D=3Dnull) {=0A> = if (trim(current.content,true,false)=3D=3D"") {=0A> return = true;=0A> }=0A> else {=0A> return t= his.error("expected document node, found: " + =0A> current);=0A> = }=0A> }=0A> else {=0A> // otherwise, append t= his as child to the element at the =0A> top of the stack=0A> re= turn this.topNode.addElement(current);=0A> }=0A> =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=0A> =3D=3D The values are being = parsed correctly but the error is showing up:=0A> My server side code that = generates the xml looks like this....=0A> =0A> response.setContentT= ype("text/xml");=0A> PrintWriter out =3D response.getWriter();=0A> = out.println("<?xml version=3D\"1.0\"?>");=0A> out.println("= <vendor>");=0A> out.println("<name>");=0A> out.println("har= ry"); =0A> out.println("</name>"); =0A> out.println("<ad= dress>");=0A> out.println("100 Cherry Tree Lane");=0A> out.= println("</address>"); =0A> out.println("</vendor>");=0A> =0A> I= s anything obviously wrong with this????=0A> =0A> Thanks,=0A> Ed=0A> =0A> >= --------------------------------------------------------------------=0A> >= -----=0A> Using Tomcat but need to do more? Need to support web services,= =0Asecurity?=0A> Get stuff done quickly with pre-integrated technology to m= ake your job=0A=0A> easier Download IBM WebSphere Application Server v.1.0.= 1 based on =0A> Apache Geronimo =0A> http://sel.as-us.falkag.net/sel?cmd=3D= lnk&kid=3D120709&bid=3D263057&dat=3D1216=0A> 42>=0A________________________= _______________________=0A> xmljs-users mailing list=0A> xmljs-users@lists.= sourceforge.net=0A> https://lists.sourceforge.net/lists/listinfo/xmljs-user= s=0A> =0A=0A=0A=0A |