On 5 juil, 19:17, fonghuangyee <[email protected]> wrote: > StringBuffer xmlBfr = new StringBuffer(); > xmlBfr.append("<Layout>"); > xmlBfr.append("<Column type=\"Middle\"></Column>"); > xmlBfr.append("<Column type=\"Middle\"></Column>"); > xmlBfr.append("</Layout>"); > String xml = xmlBfr.toString(); > Document document = XMLParser.parse(xml); > Element element = document.getDocumentElement(); > NodeList layouts = element.getElementsByTagName("Layout"); > for (int k = 0; k < layouts.getLength(); ++k) { > Element layoutElement = (Element) layouts.item(k); > NodeList columns = layoutElement.getElementsByTagName("Column"); > for (int i = 0; i < columns.getLength(); ++i) { > Element columnElement = (Element) columns.item(i); > String type = columnElement.getAttribute("type"); > Window.alert(type); > } > > } > > I try run the code above, i found that the XMLParser is not working > well. > NodeList layouts = element.getElementsByTagName("Layout"); > layouts.getLength() should return 1, but it is return 0! > XMLParser just cant parse the xml string. > > May i know, am i doing any mistake when using XMLParser as above?
The "document element" *is* the <Layout> ! -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. 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.
