Java Code Examples for com.google.gwt.xml.client.Document#getDocumentElement()

The following examples show how to use com.google.gwt.xml.client.Document#getDocumentElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DialogXML.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public Dialog unmarshall(String xml)
{

    try {
        Document document = XMLParser.parse(xml);
        Element root = document.getDocumentElement();

        // model
        Builder builder = new Builder();
        dfsElement(builder, DOMUtils.getFirstChildElement(root));

        // dialog
        Dialog dialog = new Dialog(new QName(root.getNamespaceURI(), root.getAttribute("id")), builder.build());

        return dialog;
    } catch (RuntimeException e) {
        Window.alert("Faile to parse XML: "+e.getMessage());
        throw e;
    }
}
 
Example 2
Source File: TestReader.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestRun read(String s) {

		Document doc = XMLParser.parse(s);
		TestRun tr = new TestRun();

		Element run = doc.getDocumentElement();

		NodeList runChildren = run.getChildNodes();
		for (int i = 0; i < runChildren.getLength(); i++) {
			Node runChild = runChildren.item(i);
			String name = runChild.getNodeName();

			switch (name) {
			case "desc":
				tr.description = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "precisionModel":
				tr.precisionModel = trim(((Element) runChild)
						.getAttribute("type"));
				break;
			case "resultMatcher":
				tr.resultMatcher = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "geometryOperation":
				tr.geometryOperation = trim(runChild.getChildNodes().item(0)
						.getNodeValue());
				break;
			case "case":
				TestCase tc = new TestCase();
				tr.testCases.add(tc);
				parseTestCase(runChild, tc);
				break;
			default:
				// sLogger.severe("-------" + name + "-------");
				break;
			}
		}

		return tr;
	}