...

View Full Version : Determining if document is XML in Gecko



Alex Vincent
02-21-2003, 07:11 PM
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.



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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum