By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,608 Members | 3,801 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,608 IT Pros & Developers. It's quick & easy.

Parsing XML with namespaces in IE.

P: n/a
With the help of this newsgroup and Google I have got this code
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByTagNameNS()" function I
cannot read the individual rates from the Cube namespace.

Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?

Here is the code. Any help gratefully received.

var doc
function load() {
if (document.implementation &&
document.implementation.createDocument){
doc = document.implementation.createDocument("", "", null);
doc.load('CEBrates.xml');
doc.onload = createTable;
}
else if (window.ActiveXObject){
var doc1 = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(xmlFile){
doc1.async="false";
doc1.onreadystatechange=verify;
doc1.load(xmlFile);
doc=doc1.documentElement;
}
loadXML('CEBrates.xml');
alert(doc.xml)
}
else {
alert('Your browser can\'t handle this script');
return;
}
}
function verify() {
if (doc1.readyState != 4 ){
return false;
}
}
function createTable() {
var cubes = doc.getElementsByTagNameNS('http://www.ecb.int/
vocabulary/2002-08-01/eurofxref','Cube');
var dateRate = cubes[1].getAttribute('time');
var dateRateSplit = dateRate.split('-');
for (var i = 2; i < cubes.length; i++){
var currency = cubes[i].getAttribute('currency');
var rate = cubes[i].getAttribute('rate');
rateObject[currency] = rate;
}
document.getElementById('boldStuff').innerHTML = dateRateSplit[2]
+ "." + dateRateSplit[1] + "." + dateRateSplit[0];
document.getElementById("currency").value = "GBP";
getRates();
};
var rateObject = {};
function getRates() {
var curr= document.getElementById("currency").value;
var currRate = rateObject[curr];
var currStatement= "1 EUR = " + currRate + " " + curr ;
document.getElementById("rate").value=currStatemen t;
var currRev=1/currRate;
currRevFix=currRev.toFixed(5);
var currRevStatement= "1 " + curr +"= " + currRevFix + " EUR";
document.getElementById("rateRev").value=currRevSt atement;
};
Nov 2 '08 #1
Share this Question
Share on Google+
20 Replies


P: n/a
On Nov 2, 3:10*pm, Steve <stephen.jo...@googlemail.comwrote:
With the help of this newsgroup and Google I have got this code
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByTagNameNS()" function I
cannot read the individual rates from the Cube namespace.
At the present time, the MS XML DOM object does not support
getElementsByTagNameNS method, but it is certainly capable of reading
data from elements in the document. See getElementsByTagName,
selectNodes and selectSingleNode.

http://msdn.microsoft.com/en-us/libr...28(VS.85).aspx
>
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?

Here is the code. Any help gratefully received.

var doc
function load() {
* *if (document.implementation &&
document.implementation.createDocument){
Always use typeof to test host methods (e.g. should be "object",
"function" or "unknown".) Testing host methods by boolean type
conversion is known to cause exceptions in IE.
* * * * * * * * doc = document.implementation.createDocument("", "", null);
* * * * * * * * doc.load('CEBrates.xml');
* * * * * * * * doc.onload = createTable;
* * * * }
* * * * else if (window.ActiveXObject){
I would test for more than "truthiness" here (should be a function.)
And you are going to need a try-catch clause to deal with cases where
ActiveX objects are disallowed, the XML DOM object is malfunctioning
or any of the other dozen things that can go wrong with the
instantiation.
* * * * * * * * var doc1 = new ActiveXObject("Microsoft..XMLDOM");
* * * function loadXML(xmlFile){
* * * * *doc1.async="false";
Why are you setting a boolean property to a string? You are lucky the
object doesn't throw an exception. No way to know if a future Windows
update will break this.
* * * * *doc1.onreadystatechange=verify;
* * * * *doc1.load(xmlFile);
* * * * *doc=doc1.documentElement;
* * * }
* * * loadXML('CEBrates.xml');
* * * alert(doc.xml)
Use window.alert.
* * * }
* * * else {
* * * * * * * * alert('Your browser can\'t handle this script');
Never do this. You are insulting the user's browser and you haven't
the slightest idea if their browser can handle your script. And
besides, how many of your users would know what you mean by "script?"
* * * * * * * * return;
* * *}}

function verify() {
* * if (doc1.readyState != 4 ){
* * * * return false;
* *}}
This function appears to be nonsense.

[snip]
Nov 3 '08 #2

P: n/a
On Nov 2, 11:30*pm, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10*pm, Steve <stephen.jo...@googlemail.comwrote:
With the help of this newsgroup and Google I have got this code
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByTagNameNS()" function I
cannot read the individual rates from the Cube namespace.

At the present time, the MS XML DOM object does not support
getElementsByTagNameNS method, but it is certainly capable of reading
data from elements in the document. *See getElementsByTagName,
selectNodes and selectSingleNode.

http://msdn.microsoft.com/en-us/libr...28(VS.85).aspx
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
Here is the code. Any help gratefully received.
var doc
function load() {
* *if (document.implementation &&
document.implementation.createDocument){

Always use typeof to test host methods (e.g. should be "object",
"function" or "unknown".) *Testing host methods by boolean type
conversion is known to cause exceptions in IE.
And, of course, if it is "object" then also test if it is
"truthy" (else null passes.) Do *not* test the "truthiness" of
"unknown" types as they will always throw exceptions. It should also
be pointed out that "unknown" is not evidence of a method, only
evidence that something is there. Removing an element from the DOM
sets lots of properties (e.g. offsetParent) to "unknown" types.

Search the group for "isHostMethod" for a safe wrapper. Pass it names
of host object properties that are known to be implemented as methods
as IE's "unknown" types make it an unreliable test otherwise (e.g.
offsetParent is not callable.)
Nov 3 '08 #3

P: n/a
This script is simply my first draft to get IE to read an XML file,
something that is straightforward with browsers that support the W3C
DOM Level 2 Core. The reason the code is messy is because I have had
to make lots of changes to get IE to even load the XML. This is why I
am asking the newsgroup for help. Thanks for answering but I'm afraid
the following response doesn't answer my question, which was "Is there
a wrapper or some other relatively simple method of getting IE to do
what in Firefox is straighforward?" I will reply to some parts of the
answer which are easy to answer and have nothing to do with the
question I asked.
On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
This is the question I would appreciate an answer to.
>
Here is the code. Any help gratefully received.
var doc
function load() {
if (document.implementation &&
document.implementation.createDocument){

Always use typeof to test host methods (e.g. should be "object",
"function" or "unknown".) Testing host methods by boolean type
conversion is known to cause exceptions in IE.
This is not causing an exception.
>
doc = document.implementation.createDocument("", "", null);
doc.load('CEBrates.xml');
doc.onload = createTable;
}
else if (window.ActiveXObject){

I would test for more than "truthiness" here (should be a function.)
And you are going to need a try-catch clause to deal with cases where
ActiveX objects are disallowed, the XML DOM object is malfunctioning
or any of the other dozen things that can go wrong with the
instantiation.
OK
var doc1 = new ActiveXObject("Microsoft.XMLDOM");
function loadXML(xmlFile){
doc1.async="false";

Why are you setting a boolean property to a string? You are lucky the
object doesn't throw an exception. No way to know if a future Windows
update will break this.
Lucky?
doc1.onreadystatechange=verify;
doc1.load(xmlFile);
doc=doc1.documentElement;
}
loadXML('CEBrates.xml');
alert(doc.xml)

Use window.alert.
Why? Alert is used everywhere even in the Rhino book.
}
else {
alert('Your browser can\'t handle this script');

Never do this. You are insulting the user's browser and you haven't
the slightest idea if their browser can handle your script. And
besides, how many of your users would know what you mean by "script?"
This is only there until the script is working. No-one will see it as
it is only on my localhost.
function verify() {
if (doc1.readyState != 4 ){
return false;
}}

This function appears to be nonsense.
This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized

Regards, Steve.
Nov 3 '08 #4

P: n/a
On Nov 3, 4:59*am, Steve <stephen.jo...@googlemail.comwrote:
This script is simply my first draft to get IE to read an XML file,
something that is straightforward with browsers that support the W3C
DOM Level 2 Core. The reason the code is messy is because I have had
to make lots of changes to get IE to even load the XML. This is why I
am asking the newsgroup for help. Thanks for answering but I'm afraid
the following response doesn't answer my question, which was "Is there
a wrapper or some other relatively simple method of getting IE to do
what in Firefox is straighforward?"
I answered that.
I will reply to some parts of the answer which are easy to answer and have nothing to do with the
question I asked.
Odd choice. It's your dime.
>
On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?

This is the question I would appreciate an answer to.
I answered it.
>

Here is the code. Any help gratefully received.
var doc
function load() {
* *if (document.implementation &&
document.implementation.createDocument){
Always use typeof to test host methods (e.g. should be "object",
"function" or "unknown".) *Testing host methods by boolean type
conversion is known to cause exceptions in IE.

This is not causing an exception.
I didn't imply that it was. In fact, your test:

if (document.implementation && document.implementation.createDocument)
{

would seem to preclude IE from evaluating the createDocument method.
Just a general note of warning.
>

* * * * * * * * doc = document.implementation.createDocument("", "", null);
* * * * * * * * doc.load('CEBrates.xml');
* * * * * * * * doc.onload = createTable;
* * * * }
* * * * else if (window.ActiveXObject){
I would test for more than "truthiness" here (should be a function.)
And you are going to need a try-catch clause to deal with cases where
ActiveX objects are disallowed, the XML DOM object is malfunctioning
or any of the other dozen things that can go wrong with the
instantiation.

OK
* * * * * * * * var doc1 = new ActiveXObject("Microsoft.XMLDOM");
* * * function loadXML(xmlFile){
* * * * *doc1.async="false";
Why are you setting a boolean property to a string? *You are lucky the
object doesn't throw an exception. *No way to know if a future Windows
update will break this.

Lucky?
I doubt it.
>
* * * * *doc1.onreadystatechange=verify;
* * * * *doc1.load(xmlFile);
* * * * *doc=doc1.documentElement;
* * * }
* * * loadXML('CEBrates.xml');
* * * alert(doc.xml)
Use window.alert.

Why? Alert is used everywhere even in the Rhino book.
I doubt that too. Perhaps alert is, but that doesn't make it right.
Why would you use an unqualified reference to that method? Seems
deliberately ambiguous.
>
* * * }
* * * else {
* * * * * * * * alert('Your browser can\'t handle this script');
Never do this. *You are insulting the user's browser and you haven't
the slightest idea if their browser can handle your script. *And
besides, how many of your users would know what you mean by "script?"

This is only there until the script is working. No-one will see it as
it is only on my localhost.
Good.
>
function verify() {
* * if (doc1.readyState != 4 ){
* * * * return false;
* *}}
This function appears to be nonsense.

This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized
Despite that, the function is still nonsense in this context. As your
code is admittedly a mess, why not pare it down a bit by removing
obviously unneeded nonsense?
Nov 3 '08 #5

P: n/a
On Nov 3, 11:17 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 3, 4:59 am, Steve <stephen.jo...@googlemail.comwrote:
This script is simply my first draft to get IE to read an XML file,
something that is straightforward with browsers that support the W3C
DOM Level 2 Core. The reason the code is messy is because I have had
to make lots of changes to get IE to even load the XML. This is why I
am asking the newsgroup for help. Thanks for answering but I'm afraid
the following response doesn't answer my question, which was "Is there
a wrapper or some other relatively simple method of getting IE to do
what in Firefox is straighforward?"

I answered that.
Then please clarify what your answer is. If it is imply giving a link
to MS XML DOM Methods please be aware that that is not very helpful. I
would appreciate some help in learning how to use these methods to do
what getElementsByTagNameNS() does.
On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
This is the question I would appreciate an answer to.

I answered it.
What is the answer? Simply giving a link to MS XML DOM Methods is not
very helpful.
doc1.onreadystatechange=verify;
doc1.load(xmlFile);
doc=doc1.documentElement;
}
loadXML('CEBrates.xml');
alert(doc.xml)
Use window.alert.
Why? Alert is used everywhere even in the Rhino book.

I doubt that too. Perhaps alert is, but that doesn't make it right.
Why would you use an unqualified reference to that method? Seems
deliberately ambiguous.
I will start the next sentence without capitalizing the first letter
as it seems that script grammar is more important to you than english
grammar. alert is a recognized method of debugging scripts. Its only
there to see if the xml has been loaded.
function verify() {
if (doc1.readyState != 4 ){
return false;
}}
This function appears to be nonsense.
This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized

Despite that, the function is still nonsense in this context. As your
code is admittedly a mess, why not pare it down a bit by removing
obviously unneeded nonsense?
It is not nonsense because it is necessary for the xml file to be
completely initialized before attempting to read it.

Nov 3 '08 #6

P: n/a
On Nov 3, 6:06*am, Steve <stephen.jo...@googlemail.comwrote:
On Nov 3, 11:17 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 3, 4:59 am, Steve <stephen.jo...@googlemail.comwrote:
This script is simply my first draft to get IE to read an XML file,
something that is straightforward with browsers that support the W3C
DOM Level 2 Core. The reason the code is messy is because I have had
to make lots of changes to get IE to even load the XML. This is why I
am asking the newsgroup for help. Thanks for answering but I'm afraid
the following response doesn't answer my question, which was "Is there
a wrapper or some other relatively simple method of getting IE to do
what in Firefox is straighforward?"
I answered that.

Then please clarify what your answer is. If it is imply giving a link
to MS XML DOM Methods please be aware that that is not very helpful. I
would appreciate some help in learning how to use these methods to do
what getElementsByTagNameNS() does.
Did you look at the examples in the documentation of any or all of the
three methods I mentioned? Is there something in particular that
confuses you?
>
On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
This is the question I would appreciate an answer to.
I answered it.

What is the answer? Simply giving a link to MS XML DOM Methods is not
very helpful.
See above.
>
* * * * *doc1.onreadystatechange=verify;
* * * * *doc1.load(xmlFile);
* * * * *doc=doc1.documentElement;
* * * }
* * * loadXML('CEBrates.xml');
* * * alert(doc.xml)
Use window.alert.
Why? Alert is used everywhere even in the Rhino book.
I doubt that too. *Perhaps alert is, but that doesn't make it right.
Why would you use an unqualified reference to that method? *Seems
deliberately ambiguous.

I will start the next sentence without capitalizing the first letter
as it seems that script grammar is more important to you than english
"Script grammar?"
grammar. alert is a recognized method of debugging scripts. Its only
there to see if the xml has been loaded.
A "recognized method" is what exactly? An implied global method? It
is indeed recognized as that and that is not a good thing. And, of
course, you should not start an English sentence in lowercase.
>

function verify() {
* * if (doc1.readyState != 4 ){
* * * * return false;
* *}}
This function appears to be nonsense.
This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized
Despite that, the function is still nonsense in this context. *As your
code is admittedly a mess, why not pare it down a bit by removing
obviously unneeded nonsense?

It is not nonsense because it is necessary for the xml file to be
completely initialized before attempting to read it.
You are completely mistaken.
Nov 3 '08 #7

P: n/a
David Mark wrote:
[...] Do *not* test the "truthiness" of "unknown" types as they will
always throw exceptions. It should also be pointed out that "unknown" is
not evidence of a method, only evidence that something is there.
Removing an element from the DOM sets lots of properties (e.g.
offsetParent) to "unknown" types.
Good remarks, thanks. I may have to refine my isMethod().
PointedEars, pressing 1, 4 ;-)
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 3 '08 #8

P: n/a
Steve wrote:
With the help of this newsgroup and Google I have got this code
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByTagNameNS()" function I
cannot read the individual rates from the Cube namespace.
With IE you use MSXML for XML DOM, it implements methods selectNodes and
selectSingleNode for DOM documents and elements (or even nodes in
general). With MSXML 3 and later you can pass an XPath 1.0 expression to
those two methods to select nodes:
var doc = new ActiveXObject('Msxml2.DOMDocument.3.0');
doc.async = false;
if (doc.load('file.xml'))
{
// necessary for MSXML 3 first:
doc.setProperty('SelectionLanguage', 'XPath');

// now bind prefixes to namespace URIs e.g.
doc.setProperty('SelectionNamespaces',
'xmlns:pf1="http://example.com/ns1" xmlns:pf2="http://example.org/ns2"');

// and use those prefixes in XPath expresssions
var nodeList = doc.selectNodes('pf1:foo/pf1:bar/pf2:baz');
// use nodeList here
}
--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 3 '08 #9

P: n/a
>On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
function verify() {
if (doc1.readyState != 4 ){
return false;
}}
This function appears to be nonsense.
This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized
Despite that, the function is still nonsense in this context. As your
code is admittedly a mess, why not pare it down a bit by removing
obviously unneeded nonsense?
It is not nonsense because it is necessary for the xml file to be
completely initialized before attempting to read it.

You are completely mistaken.
I am asking for assistance here and you are only muddying the waters.
What am I mistaken about in your opinion? My understanding is that the
object (xml file) must be "ready state 4" before starting to be read.
You say that I am completely mistaken. Perhaps I am, but do you really
think this sort of reply is helpful?

Nov 3 '08 #10

P: n/a
On Nov 3, 8:31*am, Steve <stephen.jo...@googlemail.comwrote:
On Nov 3, 5:30 am, David Mark <dmark.cins...@gmail.comwrote:
On Nov 2, 3:10 pm, Steve <stephen.jo...@googlemail.comwrote:
function verify() {
* * if (doc1.readyState != 4 ){
* * * * return false;
* *}}
This function appears to be nonsense.
This function is perfectly ok. Ready states are:
0 Object is not initialized
1 Loading object is loading data
2 Loaded object has loaded data
3 Data from object can be worked with
4 Object completely initialized
Despite that, the function is still nonsense in this context. *Asyour
code is admittedly a mess, why not pare it down a bit by removing
obviously unneeded nonsense?
It is not nonsense because it is necessary for the xml file to be
completely initialized before attempting to read it.
You are completely mistaken.

I am asking for assistance here and you are only muddying the waters.
Am I? Perhaps you are not equipped to deal with the assistance
offered?
What am I mistaken about in your opinion? My understanding is that the
object (xml file) must be "ready state 4" before starting to be read.
You say that I am completely mistaken. Perhaps I am, but do you really
think this sort of reply is helpful?
I have escalated your case. Somebody from level 2 support with be
with you shortly. Thank you for using comp.lang.javascript.
Nov 3 '08 #11

P: n/a
David Mark wrote:
On Nov 3, 8:31 am, Steve <stephen.jo...@googlemail.comwrote:
>What am I mistaken about in your opinion? My understanding is that the
object (xml file) must be "ready state 4" before starting to be read.
You say that I am completely mistaken. Perhaps I am, but do you really
think this sort of reply is helpful?

I have escalated your case. Somebody from level 2 support with be
with you shortly. Thank you for using comp.lang.javascript.
ROTFL. YMMD! :)
PointedEars, formerly first-then-second-level support
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Nov 3 '08 #12

P: n/a
On Nov 3, 4:14*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
On Nov 3, 8:31 am, Steve <stephen.jo...@googlemail.comwrote:
What am I mistaken about in your opinion? My understanding is that the
object (xml file) must be "ready state 4" before starting to be read.
You say that I am completely mistaken. Perhaps I am, but do you really
think this sort of reply is helpful?
I have escalated your case. *Somebody from level 2 support with be
with you shortly. *Thank you for using comp.lang.javascript.

ROTFL. *YMMD! :)

PointedEars, formerly first-then-second-level support
LOL. Did you get kicked upstairs?
Nov 3 '08 #13

P: n/a
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>On Nov 3, 8:31 am, Steve <stephen.jo...@googlemail.comwrote:
What am I mistaken about in your opinion? My understanding is that the
object (xml file) must be "ready state 4" before starting to be read.
You say that I am completely mistaken. Perhaps I am, but do you really
think this sort of reply is helpful?
I have escalated your case. Somebody from level 2 support with be
with you shortly. Thank you for using comp.lang.javascript.
ROTFL. YMMD! :)

PointedEars, formerly first-then-second-level support

LOL. Did you get kicked upstairs?
Yep, and believe me, work was a lot more fun then :)
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Nov 3 '08 #14

P: n/a
On Nov 3, 6:53*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
[...] *Do *not* test the "truthiness" of "unknown" types as they will
always throw exceptions. *It should also be pointed out that "unknown" is
not evidence of a method, only evidence that something is there.
Removing an element from the DOM sets lots of properties (e.g.
offsetParent) to "unknown" types.

Good remarks, thanks. *I may have to refine my isMethod().
Has isMethodType been retired? Everyone should be using some
variation of this as the number of "unknown" types may grow with IE8.
I suppose it is possible they could add new types as well. Why they
(MS) would do this is anyone's guess. But such behavior is clearly
allowed for host objects and IE has been more or less consistent in
this regard for a decade. IE7 did add a couple of new "unknown"
wrinkles, but they follow the same rules.

At the very least, those who wish to implement proper feature testing
should be aware of this issue. It helps to avoid such train-of-
thought wrecks as this:

http://ejohn.org/blog/future-proofin...ipt-libraries/

I have seen numerous attempts at explanations for the bizarre
getAttribute comment (none by the author of course.) I am certain
that there are circumstances in IE where evaluating this host object
method will throw an exception. I am also certain that the typeof
operator will safely reveal its type as "unknown" in all such cases.
IIRC, IE's XML elements have always been rigged to explode in this way.
Nov 3 '08 #15

P: n/a
On Nov 3, 1:03*pm, Martin Honnen <mahotr...@yahoo.dewrote:
With IE you use MSXML for XML DOM, it implements methods selectNodes and
selectSingleNode for DOM documents and elements (or even nodes in
general). With MSXML 3 and later you can pass an XPath 1.0 expression to
those two methods to select nodes:
* *var doc = new ActiveXObject('Msxml2.DOMDocument.3.0');
* *doc.async = false;
* *if (doc.load('file.xml'))
* *{
* * * // necessary for MSXML 3 first:
* * * doc.setProperty('SelectionLanguage', 'XPath');

* * * // now bind prefixes to namespace URIs e.g.
* * * doc.setProperty('SelectionNamespaces',
'xmlns:pf1="http://example.com/ns1" xmlns:pf2="http://example.org/ns2"');

* * * // and use those prefixes in XPath expresssions
* * * var nodeList = doc.selectNodes('pf1:foo/pf1:bar/pf2:baz');
* * * // use nodeList here
* *}
Thank you Martin for a helpful reply. I have now got IE reading the
XML thanks to your post.

Regards,

Steve

Nov 3 '08 #16

P: n/a
On Nov 3, 1:03*pm, Martin Honnen <mahotr...@yahoo.dewrote:
With IE you use MSXML for XML DOM, it implements methods selectNodes and
selectSingleNode for DOM documents and elements (or even nodes in
general). With MSXML 3 and later you can pass an XPath 1.0 expression to
those two methods to select nodes:
* *var doc = new ActiveXObject('Msxml2.DOMDocument.3.0');
* *doc.async = false;
* *if (doc.load('file.xml'))
* *{
* * * // necessary for MSXML 3 first:
* * * doc.setProperty('SelectionLanguage', 'XPath');

* * * // now bind prefixes to namespace URIs e.g.
* * * doc.setProperty('SelectionNamespaces',
'xmlns:pf1="http://example.com/ns1" xmlns:pf2="http://example.org/ns2"');

* * * // and use those prefixes in XPath expresssions
* * * var nodeList = doc.selectNodes('pf1:foo/pf1:bar/pf2:baz');
* * * // use nodeList here
* *}
Thank you Martin for a helpful reply. I have now got IE reading the
XML thanks to your post.

Regards,

Steve

Nov 3 '08 #17

P: n/a
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
>Thomas 'PointedEars' Lahn wrote:
>>David Mark wrote:
[...] Do *not* test the "truthiness" of "unknown" types as they will
always throw exceptions. It should also be pointed out that "unknown" is
not evidence of a method, only evidence that something is there.
Removing an element from the DOM sets lots of properties (e.g.
offsetParent) to "unknown" types.
Good remarks, thanks. I may have to refine my isMethod().
Has isMethodType been retired?

I have replaced it largely with isMethod() in dhtml.js [...]
JFTR: dhtml.js:_addEventListener():3 which is

if (o && sEvent && isMethodType(fListener) && fListener)

should be

if (o && sEvent && isMethodType(typeof fListener) && fListener)

This bug is FIXED since version 0.9.4.2008042321 (unreleased).
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Nov 4 '08 #18

P: n/a
On Nov 4, 1:49*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
[...] *Do *not* test the "truthiness" of "unknown" types as they will
always throw exceptions. *It should also be pointed out that "unknown" is
not evidence of a method, only evidence that something is there.
Removing an element from the DOM sets lots of properties (e.g.
offsetParent) to "unknown" types.
Good remarks, thanks. *I may have to refine my isMethod().
Has isMethodType been retired?

I have replaced it largely with isMethod() in dhtml.js (which is going tobe
renamed to dom.js or something like that -- existing URIs are still goingto
work). *However, there are some instances where I think isMethodType() is
still needed.
[typeof x == "unknown"]
At the very least, those who wish to implement proper feature testing
should be aware of this issue. *It helps to avoid such train-of-
thought wrecks as this:
http://ejohn.org/blog/future-proofin...ipt-libraries/

OMG.
Indeed. Odd that hasn't been pulled by now. Everybody who reads it
has the same reaction. Well, most everybody. See today's posts on
the subject.
Nov 4 '08 #19

P: n/a
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>[...] Do *not* test the "truthiness" of "unknown" types as they will
always throw exceptions. It should also be pointed out that "unknown" is
not evidence of a method, only evidence that something is there.
Removing an element from the DOM sets lots of properties (e.g.
offsetParent) to "unknown" types.
Good remarks, thanks. I may have to refine my isMethod().

Has isMethodType been retired?
I have replaced it largely with isMethod() in dhtml.js (which is going to be
renamed to dom.js or something like that -- existing URIs are still going to
work). However, there are some instances where I think isMethodType() is
still needed.
[typeof x == "unknown"]
At the very least, those who wish to implement proper feature testing
should be aware of this issue. It helps to avoid such train-of-
thought wrecks as this:

http://ejohn.org/blog/future-proofin...ipt-libraries/
OMG.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 4 '08 #20

P: n/a
On Nov 4, 8:04*pm, David Mark <dmark.cins...@gmail.comwrote:
On Nov 4, 1:49*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>[...] *Do *not* test the "truthiness" of "unknown" types as they will
>>always throw exceptions. *It should also be pointed out that "unknown" is
>>not evidence of a method, only evidence that something is there.
>>Removing an element from the DOM sets lots of properties (e.g.
>>offsetParent) to "unknown" types.
>Good remarks, thanks. *I may have to refine my isMethod().
Has isMethodType been retired?
I have replaced it largely with isMethod() in dhtml.js (which is going to be
renamed to dom.js or something like that -- existing URIs are still going to
work). *However, there are some instances where I think isMethodType() is
still needed.
[typeof x == "unknown"]
At the very least, those who wish to implement proper feature testing
should be aware of this issue. *It helps to avoid such train-of-
thought wrecks as this:
>http://ejohn.org/blog/future-proofin...ipt-libraries/
OMG.

Indeed. *Odd that hasn't been pulled by now. *Everybody who reads it
has the same reaction. *Well, most everybody. *See today's posts on
the subject.
Have you two wankers finished hijacking this thread?
Nov 7 '08 #21

This discussion thread is closed

Replies have been disabled for this discussion.