Sometimes it matters if a document is an XML document or not -- or, more accurately, if Mozilla, Netscape, KMeleon, and family will treat a document as XML.

For instance, I'm building a widget to create nodes in the DOM, but HTML documents don't allow namespaces. XHTML as XML does.

Code:
function docIsXML(doc) {
  var ifaces = Components.interfaces;
  return ((doc instanceof ifaces.nsIDOMXMLDocument)||(doc instanceof ifaces.nsIDOMXULDocument));
}
XUL documents, while considered XML documents, aren't registered as such in the current Mozilla implementation. But if they someday are, this code will still detect that correctly.