The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

XML, Javascript and cross-browser compatibility

Hi!
I'm trying to read an XML file with Javascript client-side and I have some cross-browser compatibitity problems.

If I build a xml object with

var objXML = new ActiveXObject("Msxml2.DOMDocument.4.0");

I read my nodes, I display them in a div and I load my page with Internet Explorer everything runs well but if I open that page with Mozilla, Opera or Netscape that object isn't created and obviously no result appear on my page.

Do you know a way to read an xml file with javascript client-side that runs well with non-ie browsers?

ActiveX is a Microsoft technology, so I wouldn't expect it to work in a browser other than IE/Windows. Try Creating a cross-browser wrapper for your XML functions. Also, there is currently no way to load XML in Opera or Konqueror/Safari, so be sure of your audience if you plan on using XML like that, or do the transformations on the server-side.

Gazingus offers an XML Parser written in JavaScript. A disclaimer is attached saying that the project was more of a learning experience for the author rather than a genuine solution, but it might help you.

This is the only link I have in my bookmarks of such a parser, but I have seen others around, perhaps more complete than this one. All just a Google away.

Wow!
Thanks to everyone has answered to my question!
There are very interesting alternates but I think I'll work on the vgarcia's one.
I've already changed a little part of my script and now it runs well under mozilla and netscape. as concern other browsers I'll found a server-side solution.

Thanks to Mr. Brownstone, that's a good parser but it too difficult to arrange to my aims :-)
And thanks to Markdidj, it's a good solution but it isn't what I'm looking for. I create and manipulate the xml file with asp and I display real time changes with js, it's more easy for me

I think it's a good solution, and the structure you have done to the js file is very interesting but at the moment all my asp scripts use XMLDOM instead of FileSystemObject, so for me it's easier to change file visualization wth js than every other thing.
Thanks a lot for your help, it give me a good idea for a chat

I've used it for my page counter and my first forum.
I know search engines won't pick it it, but it's not really needed.

If anyone wants to use it for forum or chat boxes its really simple to use, and good for sites with low bandwidth ( javascript gets used from cache client-side unless changed )

My forum HTML page stays the same. The page reads the messageCount.js and finds the total number of messages for that forum. I then use this to check the messages wishing to be read, as the messages are saved in groups of 10. (index0.js, index1.js, index2.js etc )

test message (testMess(Obj)) checks that no attributes are set after a HTML tag and disallowes script,img,frames and H1 tags. The rest of preSendMess() enables escapement of characters through my perl and script.

2 questions: Is testMess() sufficient to do its job, and is there a way I can condense preSendMess() ? It seems long winded....

Added: Just been for a dog walk ( always good for inspiration (no :dog: but exists for the ladies?? )) and realised I don't actually use it for my forum, apart from checking if new messages exist (changeScript("messageCount")), but I am going to use it to display new messages in the future.....