Java examples for XML:XML Node
Attempts to match the provided node to the XML Element type with the tag name provided.
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /**//from w w w . j a v a 2s . c o m * Attempts to match the provided node to the Element type with the tag name * provided. * * @param node * The node object. * @param tagName * The tag name. * @param caseSensitive * If the match should be treated as case-sensitive. * @return If the Node object is an Element and has a tag name of that * provided. */ public static boolean isNodeOfType(Node node, String tagName, boolean caseSensitive) { if (!(node instanceof Element)) return false; Element nodeAsElement = (Element) node; if (caseSensitive && nodeAsElement.getTagName().equals(tagName)) return true; if (!caseSensitive && nodeAsElement.getTagName().equalsIgnoreCase(tagName)) return true; return false; } }