Verify Root Element is html in the XHTML namespace

      boolean valid = true;       
      DocType doctype = document.getDocType();
    
      if (doctype == null) {
        valid = false;
      }
      else {
        // check doctype
      }
    
      Element root = document.getRootElement();
      String uri = root.getNamespaceURI();
      String prefix = root.getNamespacePrefix();
      if (!uri.equals("http://www.w3.org/1999/xhtml")) {
        valid = false;
      }
      if (!prefix.equals("")) valid = false;

Previous | Next | Top | Cafe con Leche

Copyright 2004 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified February 5, 2004