com.google.gwt.xml.client.NodeList Java Examples
The following examples show how to use
com.google.gwt.xml.client.NodeList.
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: BookXmlSerdes.java From requestor with Apache License 2.0 | 6 votes |
private Book[] parseXmlDocumentAsBook(Document xml) { final NodeList idNodes = xml.getElementsByTagName("id"); final NodeList titleNodes = xml.getElementsByTagName("title"); final NodeList authorNodes = xml.getElementsByTagName("author"); final NodeList publicationDateNodes = xml.getElementsByTagName("publicationDate"); int length = idNodes.getLength(); Book[] books = new Book[length]; for (int i = 0; i < length; i++) { String id = ((Text) idNodes.item(i).getFirstChild()).getData(); String title = ((Text) titleNodes.item(i).getFirstChild()).getData(); String author = ((Text) authorNodes.item(i).getFirstChild()).getData(); String publicationDate = ((Text) publicationDateNodes.item(i).getFirstChild()).getData(); books[i] = new Book(Integer.valueOf(id), title, author, new Date(Long.valueOf(publicationDate))); } return books; }
Example #2
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 #3
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 #4
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 #5
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 #6
Source File: PropertiesManager.java From SensorWebClient with GNU General Public License v2.0 | 5 votes |
public ArrayList<String> getParameters(String name) { ArrayList<String> array = new ArrayList<String>(); if (hasProperty(name)) { NodeList nodes = this.properties.getElementsByTagName(name); for (int i = 0; i < nodes.getLength(); i++) { array.add(nodes.item(i).getFirstChild().toString()); } } return array; }
Example #7
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 #8
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); } }