The following code catch an exception in IE, with number -2146827850 - var xmldoc=XmlDocument.create("1str","2str");
-
xmldoc.documentElement.setAttribute('code',code);
-
var node;
-
try{
-
node=xmldoc.createElementNS('urn', 'condition');
-
}catch(e)
-
{ }
It seems that IE dosn't implement createElementNS function. Is there any way to work around it?
I need your help!
4 9715
The following code catch an exception in IE, with number -2146827850 - var xmldoc=XmlDocument.create("1str","2str");
-
xmldoc.documentElement.setAttribute('code',code);
-
var node;
-
try{
-
node=xmldoc.createElementNS('urn', 'condition');
-
}catch(e)
-
{ }
It seems that IE dosn't implement createElementNS function. Is there any way to work around it?
I need your help!
I don't know what you are talking about. I havn't heard about createElementNS function. But if you want to parse xml text, then refer to the code below. Hope it helps. -
1 /**
-
2 * Create a new Document object. If no arguments are specified,
-
3 * the document will be empty. If a root tag is specified, the document
-
4 * will contain that single root tag. If the root tag has a namespace
-
5 * prefix, the second argument must specify the URL that identifies the
-
6 * namespace.
-
7 */
-
8 XML.newDocument = function(rootTagName, namespaceURL) {
-
9 if (!rootTagName) rootTagName = "";
-
10 if (!namespaceURL) namespaceURL = "";
-
11 if (document.implementation && document.implementation.createDocument) {
-
12 // This is the W3C standard way to do it
-
13 return document.implementation.createDocument(namespaceURL, rootTagName, null);
-
14 }
-
15 else { // This is the IE way to do it
-
16 // Create an empty document as an ActiveX object
-
17 // If there is no root element, this is all we have to do
-
18 var doc = new ActiveXObject("MSXML2.DOMDocument");
-
19 // If there is a root tag, initialize the document
-
20 if (rootTagName) {
-
21 // Look for a namespace prefix
-
22 var prefix = "";
-
23 var tagname = rootTagName;
-
24 var p = rootTagName.indexOf(':');
-
25 if (p != -1) {
-
26 prefix = rootTagName.substring(0, p);
-
27 tagname = rootTagName.substring(p+1);
-
28 }
-
29 // If we have a namespace, we must have a namespace prefix
-
30 // If we don't have a namespace, we discard any prefix
-
31 if (namespaceURL) {
-
32 if (!prefix) prefix = "a0"; // What Firefox uses
-
33 }
-
34 else prefix = "";
-
35 // Create the root element (with optional namespace) as a
-
36 // string of text
-
37 var text = "<" + (prefix?(prefix+":"):"") + tagname +
-
38 (namespaceURL
-
39 ?(" xmlns:" + prefix + '="' + namespaceURL +'"')
-
40 :"") +
-
41 "/>";
-
42 // And parse that text into the empty document
-
43 doc.loadXML(text);
-
44 }
-
45 return doc;
-
46 }
-
47 };
-
createElementNS does exist. IE doesn't support it because it can't deal with XHTML properly. Use createElement instead for IE. See this link.
thank you all ! I got it.
No problem. You're welcome.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike Kamermans |
last post by:
I'm trying to determine where inside an XHTML's DOM a javascript function
is triggered, but when I use the construction of calling a function with
"this" as parameter and then checking the event...
|
by: Nicolas VanOrton |
last post by:
Hi all,
When XercesDOMParser parses an XML document in a file, if a Schema is
attached, it automatically adds all attributes with default values to
the corresponding nodes...
I'm trying to...
|
by: Eric Sessoms |
last post by:
I am trying to create forms on the fly in strict xhtml using
javascript. I won't bore you with why, but I should mention that I'm
only interested in the very latest versions of Mozilla based...
|
by: Matt Kruse |
last post by:
http://www.JavascriptToolbox.com/bestpractices/
I started writing this up as a guide for some people who were looking for
general tips on how to do things the 'right way' with Javascript. Their...
|
by: BakedBean |
last post by:
Hi,
This is probably really simple, but I've only just been asked to look
at this and I've spent a full day trying to get it to work, so any help
will be very gratefully received!
At present...
|
by: ged |
last post by:
Hi,
i am a oo (c#) programmer, and have not used javascript for a while and
i cant work out how javascript manages its references. Object
References work for simple stuff, but once i have an...
|
by: E |
last post by:
I am having trouble with setTimeout working on a second call to the
setTimeout function from a second page which is an html page.
Here is the scenario.
I have a web page and onload it calls a...
|
by: praskuma |
last post by:
Hi All
document.createElementNS works fine on firefox, but not on IE.
I use this fuction to create SVG objects on the fly
for example.....
SVG.ns = "http://www.w3.org/2000/svg";
var svg...
|
by: Holger Jeromin |
last post by:
Hello,
i need to add SVG things direct in a Website. I know XHTML is best used
for that, with works nice in Firefox and Opera.
Internet Explorer is more challenging...
I have ported my...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |