XML2Object JSXML object converter

I found an actionscript version of this script quite some time ago. I’ve used it heavily and had need of the same thing in Javascript. So, here’s the JS version of it.

XML2Object Example

Essentially this script allows you to pass an XMLNode object and it will return a Javascript tree’d object for you. If your xml document looks like this…

  <note id="note 1">This is the text for note 1</note>
  <note id="note 2">This is the text for note 2</note>

Then your JS object would give you access like this…
xml.notes.note[‘note 1’].value

It also gives you access to the original xmlNode object from which it was derived…

IE’s primary layout bug

I learned today what actually causes the majority of the CSS problems I run into with IE. It’s a property of each page element called hasLayout. Only the standard HTML tags (P, H1, BLOCKQUOTE, etc) have layout by default. There are a number of ways to force hasLayout to be enabled without affecting the layout of the element. The easiest and most fool proof that I’ve found is to add the following style to your object:


If you are familiar with the underscore hack you know that only IE will respect this rule.

For a much more detailed explaination you can visit this well written page: