Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-21-2003, 06:11 PM   PM User | #1
Alex Vincent
Moderator


 
Join Date: May 2002
Location: Hayward, CA
Posts: 1,427
Thanks: 1
Thanked 19 Times in 17 Posts
Alex Vincent is on a distinguished road
Determining if document is XML in Gecko

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.
__________________
"The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
June 30, 2001
author, Verbosio prototype XML Editor
author, JavaScript Developer's Dictionary
https://alexvincent.us/blog
Alex Vincent is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:26 AM.


Advertisement
Log in to turn off these ads.