473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Testing for an XML parser

CES
All,
Is their a way of testing if their is an XML parser installed and what the
version number is with in JavaScript???
Thanks in advance.
CES
Jul 23 '05 #1
1 1491


CES wrote:
Is their a way of testing if their is an XML parser installed and what the
version number is with in JavaScript???


If you are thinking about MS IE on Windows then you can test for Msxml e.g.

<script type="text/jscript">
var xmlDocument = null;
var highestVersion = 0;
var currentVersion;
var versionStrings = [
'Msxml2.DOMDocument.3.0',
'Msxml2.DOMDocument.4.0',
'Msxml2.DOMDocument.5.0',
'Msxml2.DOMDocument.6.0',
];
if (typeof ActiveXObject != 'undefined') {
for (var v = 0; v < versionStrings.length; v++) {
try {
currentVersion = versionStrings[v];
xmlDocument = new ActiveXObject(currentVersion);
highestVersion = currentVersion;
}
catch (e) {
break;
}
}
}
if (highestVersion) {
alert('Found support for ' + hightestVersion);
}
else {
alert('No support for found.');
}

</script>

The above should show the latest version of Msxml2.DOMDocument
available. Note that it only checks for versions that implement the W3C
XSLT and XPath 1.0 recommendation while there are earlier version like
Msxml2.DOMDocument.2.6 and 2.0 I think which allow DOM scripting but are
not compliant with the XSLT/XPath standards thus if you don't need
XPath/XSLT you might want to check for the earlier version too.

For DOM compliant implementations in browsers like Mozilla, Netscape 7
or Opera 7 you could try DOM methods like hasFeature e.g.
document.implementation.hasFeature('XML', '1.0')
document.implementation.hasFeature('Core', '2.0')
but only Mozilla thinks it has enough support to yield true on those
both while Opera 7.50 even for 1.0 returns false.

Other than that I am not sure what you have in mind with a version number.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tom Verbeure | last post by:
Hello All, so I'm now convinced that unit testing is really the way to go and I want to add it to an existing project. The first thing that I find out, is that, well, it's hard work. Harder than...
1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
0
by: Badebecq | last post by:
I am new to Java and XML and I am trying to solve a problem that has bothered for few days. I have download the parser Xerser-1.4.4 and j2sdk1.4.1_04 I install the JDK first and test it, it...
11
by: Richard | last post by:
www.geocities.com/r_bullis/test1.html At least this menu works in netscape. Disregarding the colors of the divisions. Those will be removed later. What I'm looking at doing is to have the...
1
by: Jacek | last post by:
Hi All! Currently I am in testing phase of developed by me in C# parser for ISO C++ and hopefully providing full support for VC++ as well. Unfortunately preprocessor has to be off now so for...
3
by: astromog | last post by:
I have some significantly extended syntax for Python that I need to create a reference implementation for. My new syntax includes new keywords, statements and objects that are sort of like classes...
7
by: Dick | last post by:
I have some simple (private) types... Friend Enum Types Value1 Value2 End Enum Friend Structure Detail Dim Type As Types End Structure
5
by: Jens Theisen | last post by:
Hello, I find it annoying that one has to write self.assertEqual(x, y) rather than just assert x == y
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.