Java Code Examples for org.w3c.dom.Node#getClass()

The following examples show how to use org.w3c.dom.Node#getClass() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: netbeans   File: DomVisitor.java    License: Apache License 2.0 5 votes vote down vote up
public void visit(Node node) {
   final Class<?> clazz = node.getClass();
   if (Element.class.isAssignableFrom(clazz)) {
      visit((Element) node);
   } else if (Document.class.isAssignableFrom(clazz)) {
      visit((Document) node);
   } else if (Text.class.isAssignableFrom(clazz)) {
      visit((Text) node);
   } else {
      throw new RuntimeException("Unhandled node class type " + clazz.getName());
   }
}
 
Example 2
Source Project: totallylazy   File: Xml.java    License: Apache License 2.0 5 votes vote down vote up
public static String contents(Node node) throws Exception {
    if (node instanceof Attr) {
        return contents((Attr) node);
    }
    if (node instanceof CharacterData) {
        return contents((CharacterData) node);
    }
    if (node instanceof Element) {
        return contents((Element) node);
    }
    throw new UnsupportedOperationException("Unknown node type " + node.getClass());
}