}
public String getName() {
+ if (element.getLocalName()!=null && !element.getLocalName().equals("")){
+ return element.getLocalName();
+ }
return element.getTagName();
}
return element.getAttributeNS(namespace, attributeName);
}
+ public NodeList getElementsByTagName(String name) {
+ return element.getElementsByTagName(name);
+ }
+
public void appendChild(Element element) {
this.element.appendChild(element);
// Element newElement = (Element) element.cloneNode(true);
public String getNamespaceAttribute() {
String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY);
- Preconditions.checkState(attribute != null && !attribute.equals(""), "Element %s must specify a %s attribute",
- toString(), XmlUtil.XMLNS_ATTRIBUTE_KEY);
+ Preconditions.checkState(attribute != null && !attribute.equals(""), "Element %s must specify namespace",
+ toString());
return attribute;
}
return element.hashCode();
}
+ public boolean hasNamespace() {
+ try {
+ getNamespaceAttribute();
+ } catch (IllegalStateException e) {
+ try {
+ getNamespace();
+ } catch (IllegalStateException e1) {
+ return false;
+ }
+ return true;
+ }
+ return true;
+ }
+
private static interface ElementFilteringStrategy {
boolean accept(Element e);
}