Java tutorial
//package com.java2s; /******************************************************************************* * Copyright 2012-2015 eBay Software Foundation * This program is dual licensed under the MIT and Apache 2.0 licenses. * Please see LICENSE for more information. *******************************************************************************/ import org.w3c.dom.Node; public class Main { /** * Check whether a name of given node is equal to a given name. Strips * namespace (if any). Case-sensitive. */ private static boolean nodeNameEqualTo(Node node, String target) { if (node == null || target == null) return false; String name = node.getNodeName(); // If target contains namespace, require exact match if (target.indexOf(':') < 0) { int index = name.indexOf(':'); if (index >= 0) name = name.substring(index + 1); // Strip namespace } return name.equals(target); } }