public Node getFirstChild() { return getChildNodes().item(0); }
public Node getLastChild() { return getChildNodes().item(getChildNodes().getLength() - 1); }
private static void removeWhitespaceInner(Node n, Node parent) { // This n is removed from the parent if n is a whitespace node if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) { Text t = (Text) n; if (t.getData().matches("[ \t\n]*")) { parent.removeChild(t); } } if (n.hasChildNodes()) { int length = n.getChildNodes().getLength(); List<Node> toBeProcessed = new ArrayList<Node>(); // We collect all the nodes to iterate as the child nodes will change // upon removal for (int i = 0; i < length; i++) { toBeProcessed.add(n.getChildNodes().item(i)); } // This changes the child nodes, but the iterator of nodes never changes // meaning that this is safe for (Node childNode : toBeProcessed) { removeWhitespaceInner(childNode, n); } } }
public Node getFirstChild() { return getChildNodes().item(0); }
public Node getFirstChild() { return getChildNodes().item(0); }
@Nullable private Node getUniqueElementByTagName(@Nonnull final String tagName) { NodeList nodes = ((Element)entryNode).getElementsByTagName(tagName); return nodes.getLength() == 1 ? nodes.item(0) : null; }
private List<Node> getNodesByTagName( Element element, String tagName ) { List<Node> nodes = new ArrayList<Node>(); NodeList list = element.getChildNodes(); for ( int i = 0; i < list.getLength(); i++ ) { Node node = list.item( i ); if ( node != null && node.getNodeName().equals( tagName ) ) { nodes.add( node ); } } return nodes; }
protected void parse(Node node) { parsed = true; if (node instanceof Element) { Element element = (Element) node; NodeList ftList = element.getElementsByTagName("FeatureTypeList"); if (ftList.getLength() == 1) { featureTypeList = new WfsFeatureTypeListInfo100(ftList.item(0)); } else { throw new IllegalArgumentException("Capabilities has no FeatureTypeList !"); } } }
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; }
protected void parse(Node node) { parsed = true; if (node instanceof Element) { Element element = (Element) node; NodeList ftList = element.getElementsByTagName("FeatureType"); for (int i = 0; i < ftList.getLength(); i++) { Node ftNode = ftList.item(i); WfsFeatureTypeInfo100 requestInfo = new WfsFeatureTypeInfo100(ftNode); featureTypes.add(requestInfo); } } }
private void addKeyWords(Node keywordListNode) { Element keywordListEl = (Element) keywordListNode; NodeList keywordList = keywordListEl.getElementsByTagName("Keyword"); for (int i = 0; i < keywordList.getLength(); i++) { Node keywordNode = keywordList.item(i); keywords.add(getValueRecursive(keywordNode)); } }
private void addKeyWords(Node keywordListNode) { Element keywordListEl = (Element) keywordListNode; NodeList keywordList = keywordListEl.getElementsByTagName("Keyword"); for (int i = 0; i < keywordList.getLength(); i++) { Node keywordNode = keywordList.item(i); keywords.add(getValueRecursive(keywordNode)); } }
@Override public String getText() { final StringBuilder result = new StringBuilder(); final NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node child = nodes.item(i); if (child.getNodeType() == Node.TEXT_NODE) result.append(child.getNodeValue()); } return result.toString(); }
private Node getNodeByTagName( Element element, String tagName ) { NodeList list = element.getChildNodes(); for ( int i = 0; i < list.getLength(); i++ ) { Node node = list.item( i ); if ( node != null && node.getNodeName().equals( tagName ) ) { return node; } } return null; }
private Node getNodeByTagName( Element element, String tagName ) { NodeList list = element.getChildNodes(); for ( int i = 0; i < list.getLength(); i++ ) { Node node = list.item( i ); if ( node != null && node.getNodeName().equals( tagName ) ) { return node; } } return null; }
private void parseLinks(@Nonnull final Document document) { NodeList linkNodes = document.getElementsByTagName(LINK_TAG); if (linkNodes != null) { Node linkNode; for (int i = 0; i < linkNodes.getLength(); i++) { linkNode = linkNodes.item(i); if (isLinkBelongToFeed(linkNode)) { setLink(linkNode); } } } }
public Node getLastChild() { return getChildNodes().item(getChildNodes().getLength() - 1); }
public Node getLastChild() { return getChildNodes().item(getChildNodes().getLength() - 1); }
@Override public void setText(final String text) { // TODO: remove ALL children? final NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node child = nodes.item(i); if (child.getNodeType() == Node.TEXT_NODE) { element.removeChild(child); } } if (!Strings.isNullOrEmpty(text)) { element.appendChild(document.createTextNode(text)); } }
protected void parse(Node node) { NamedNodeMap attributes = node.getAttributes(); type = getValueRecursive(attributes.getNamedItem("type")); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); String nodeName = child.getNodeName(); if ("Format".equalsIgnoreCase(nodeName)) { format = getValueRecursive(child); } else if ("OnlineResource".equalsIgnoreCase(nodeName)) { onlineResource = createOnlineResource(child); } } }