List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:Main.java
public static QName getQName(Node n) { if (n.getLocalName() != null) { return new QName(n.getNamespaceURI(), n.getLocalName()); } else {// www .j av a 2s. c o m return new QName(n.getNamespaceURI(), n.getNodeName()); } }
From source file:Main.java
/** * Gets XML node name.//from w w w . j a va2s . c o m * * @param node node. * @return node name. */ public static String getSimpleName(final Node node) { return node.getLocalName() == null ? node.getNodeName().substring(node.getNodeName().indexOf(':') + 1) : node.getLocalName(); }
From source file:Main.java
/** * Gets the qualified name of a DOM node. * /*from w w w . j ava2 s . com*/ * @param node * A DOM node. * @return A QName representing a qualified name. */ public static QName getQName(Node node) { String localName = (null == node.getLocalName()) ? "" : node.getLocalName(); return new QName(node.getNamespaceURI(), localName); }
From source file:Main.java
/** Helper method - gets the local name of the node without the namespace prefix. The method checks to be sure that the DOM 2 interface is implemented otherwise an exception is thrown when the method is called. @param pNode A <I>org.w3c.dom.Node</I> object. @return the local name.//from w w w . j av a 2 s . co m */ public static String getLocalName(Node pNode) { try { return pNode.getLocalName(); } catch (NoSuchMethodError pEx) { return pNode.getNodeName(); } }
From source file:Main.java
public static Set<String> getNodeNames(Set<Node> nodes) { Set<String> names = new HashSet<String>(); for (Node node : nodes) { names.add(node.getLocalName()); }/*from w w w . java 2 s .c om*/ return names; }
From source file:Main.java
public static QName createQName(Node node) { return new QName(node.getNamespaceURI(), node.getLocalName()); }
From source file:Main.java
public static List<Node> getChildrenbyNodeName(Node parentNode, String nameOfChildrenToFind) { NodeList childNodes = parentNode.getChildNodes(); List<Node> listToReturn = new ArrayList<Node>(); for (int i = 0; i < childNodes.getLength(); i++) { Node currentChildNode = childNodes.item(i); if (currentChildNode.getLocalName().equals(nameOfChildrenToFind)) listToReturn.add(currentChildNode); }//from w w w. j av a 2 s . c om return listToReturn; }
From source file:Main.java
public static Node getChildNode(Node node, String childName) { NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node curNode = nodes.item(i); if (curNode.getLocalName() != null && curNode.getLocalName().equals(childName)) { return curNode; }//from w ww. jav a 2 s. c o m } return null; }
From source file:Main.java
/** * Determines the first child node of the parent with the specified tag * name.//from www . j a v a 2s . c om * * @param parent The parent node of the child node to be determined. * @param nodeName The name of the child node to be determined. * * @return The determined child node with the given name. */ public static Node getChildWithName(Node parent, String nodeName) { if (parent != null) { NodeList childs = parent.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node child = childs.item(i); if ((child.getLocalName() != null) && child.getLocalName().equals(nodeName)) { return childs.item(i); } } } return null; }
From source file:Main.java
public static Node getChildElement(Node parent, String elementName) { NodeList childNodes = parent.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String nodeName = childNode.getLocalName(); if (elementName.equals(nodeName)) { return childNode; }/*www . j a va 2 s . c om*/ } return null; }