GWT's methods of implementing the DOM objects and the XML objects are totally different. The DOM implementation extends JavaScriptObject, whereas the XML objects encapsulate their JavaScriptObject structures. I would advise using the method I suggested, since it'll take a lot less of your time (and be technically a lot safer) than trying to do hackery with GWT's XML package.
String responseFromServer = ...; Element domElement = Document.get().createDivElement(); domElement.setInnerHtml(responseFromServer); NodeList<Node> children = domElement.getChildNodes(); If you need to work with sub-elements of the HTML / XML returned from the server, I would suggest using RPC, or embedding the HTML inside CDATA sections of the returned XML document. If you really feel the need to work with the HTML / XML by hand, you may need to make a copy of the GWT xml / xml.impl packages and expose the underlying JavaScriptObjects that make up the DOM structure (and even then: I'm not sure it'll work). Cristiano wrote: > Thank you, > > And do you know if can find a solution which may works even if only > inside a specific browser? > On Firefox the underlaying DOM objects tyep are the same if you use an > XHTML page and correclty handle the namespaces in the XML of the HTTP > response. > I'm able to get what I want with javascript on FF, and by the way my > gwt solution only need to work on this browser: I need gwt for other > purpose than broswser portability. > > My question may change the into: do you know how to convert elements > in "XML" package to elements in "DOM" package in Firefox by using GWT? > > Thnak you again, > Cristiano > > > > > Jason Morris wrote: >> This is something you simply can't do cleanly across all the browsers. The >> elements returned by the >> XMLParser are totally different classes to the HTMLParser. The way to do >> this is to set the >> innerHTML on an HTML Element object to the value returned from the >> RequestBuilder. Then you can use >> the normal Element.getChildNodes() to fetch the DOM objects that were >> returned from the service. >> >> Cristiano wrote: >>> Hello Everyone, >>> >>> How to 'cast' or 'transform' a "com.google.gwt.xml.client.Document" to >>> a "com.google.gwt.dom.client.Document" ??? >>> >>> I'm dealing with the requirement of handling DOM elements retrieved by >>> a server (as an HTTP "xml/text" response), parse them with XMLParser >>> and them into an existing document: >>> >>> I handle the DOM of the current page with >>> com.google.gwt.dom.client.Document and com.google.gwt.user.client.DOM. >>> >>> I handle the HTTP request with the RequestBuilder. >>> >>> I parse them with com.google.gwt.xml.client.XMLParser. >>> >>> However the "com.google.gwt.xml.client.XMLParser" do return a >>> "com.google.gwt.dom.client.Document", and I cannot add it to a >>> "com.google.gwt.dom.client.Document" because appendChild does not >>> accept as input a "com.google.gwt.xml.client.Element": it wants a >>> "com.google.gwt.doc.client.Element". >>> >>> Can you help me in find the right direction resolve this (I'm using >>> eclipse)? >>> >>> Thanks, >>> Cristiano >>> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---