Java Code Examples for com.google.gwt.xml.client.NodeList#item()
The following examples show how to use
com.google.gwt.xml.client.NodeList#item() .
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: YaBlocksEditor.java From appinventor-extensions with Apache License 2.0 | 5 votes |
public Set<String> getBlockTypeSet() { Set<String> blockTypes = new HashSet<String>(); String xmlString = blocksArea.getBlocksContent(); Document blockDoc = XMLParser.parse(xmlString); NodeList blockElements = blockDoc.getElementsByTagName("block"); for (int i = 0; i < blockElements.getLength(); ++i) { Element blockElem = (Element) blockElements.item(i); blockTypes.add(blockElem.getAttribute("type")); } return blockTypes; }
Example 2
Source File: TestReader.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
private void parseTestCase(Node case0, TestCase tc) { NodeList caseChildren = case0.getChildNodes(); for (int i = 0; i < caseChildren.getLength(); i++) { Node caseChild = caseChildren.item(i); String name = caseChild.getNodeName(); switch (name) { case "desc": tc.description = trim(caseChild.getChildNodes().item(0) .getNodeValue()); break; case "a": tc.geometryA = trim(caseChild.getChildNodes().item(0) .getNodeValue()); break; case "b": tc.geometryB = trim(caseChild.getChildNodes().item(0) .getNodeValue()); break; case "test": Test t = new Test(); tc.tests.add(t); parseTest(caseChild, t); break; default: // sLogger.severe("-------" + name + "-------"); break; } } }
Example 3
Source File: DMRAdapter.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public DMRMapping fromXML(Node node) { DMRMapping mapping = new DMRMapping(); Node address = node.getAttributes().getNamedItem("address"); if(address !=null) { mapping.setAddress(address.getNodeValue()); } NodeList children = node.getChildNodes(); List<String> attributes = new LinkedList<String>(); List<String> objects = new LinkedList<String>(); for(int i=0; i<children.getLength(); i++) { Node child = children.item(i); if(!( Node.ELEMENT_NODE == child.getNodeType())) continue; if(child.getNodeName().equals("attribute")) { attributes.add(child.getAttributes().getNamedItem("name").getNodeValue()); } else if(child.getNodeName().equals("object")) { objects.add(child.getAttributes().getNamedItem("name").getNodeValue()); } } mapping.addAttributes(attributes); mapping.addObjects(objects); return mapping; }
Example 4
Source File: DOMUtils.java From core with GNU Lesser General Public License v2.1 | 5 votes |
public static Node getFirstChildElement(Node parent) { NodeList children = parent.getChildNodes(); for(int i=0; i<children.getLength(); i++) { Node child = children.item(i); if(child.getNodeType() == Node.ELEMENT_NODE) return child; } return null; }
Example 5
Source File: TestReader.java From jts with GNU Lesser General Public License v2.1 | 4 votes |
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; }
Example 6
Source File: DialogXML.java From core with GNU Lesser General Public License v2.1 | 4 votes |
private void dfsElement(Builder builder, Node root) { // the node itself ElementAdapter adapter = getAdapter(root.getNodeName()); if(InteractionUnit.class == adapter.getType()) { // interaction unit contents InteractionUnit unit = (InteractionUnit)adapter.fromXML(root); if(unit instanceof Container) builder.start((Container)unit); else builder.add(unit); // it's children NodeList children = root.getChildNodes(); for(int i=0; i<children.getLength(); i++) { Node child = children.item(i); // skip anything except elements if(! (Node.ELEMENT_NODE == child.getNodeType())) continue; if(child.hasChildNodes()) { dfsElement(builder, child); } else { ElementAdapter childAdapter = getAdapter(child.getNodeName()); if(DMRMapping.class==childAdapter.getType()) builder.mappedBy((DMRMapping)childAdapter.fromXML(child)); else if(InteractionUnit.class==childAdapter.getType()) builder.add((InteractionUnit)childAdapter.fromXML(child)); } } if(unit instanceof Container) builder.end(); } else if (DMRMapping.class == adapter.getType()) { // dmr mapping contents DMRMapping mapping = (DMRMapping) adapter.fromXML(root); builder.mappedBy(mapping); } }