Forum Moderators: open

Message Too Old, No Replies

DOM Question

         

chrisjoha

5:42 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



I'm building an AJAX application (my first). I've made it work as intended in Firefox, but IE chokes. The response I get from the server is XML and I parse it to create a table displayed on the page. However, when dealing with attributes in the response IE stops playing along. I have this:

<date year="2005" month="09" day="06">2005-09-06</date>

Which I fetch like this:

var dateAttr = trips[i].getElementsByTagName('date')[0].attributes;
var month = dateAttr['month'].nodeValue;

And IE says "month.nodeValue" is null or not a value. What am I doing wrong here?

Bernard Marx

7:35 pm on Sep 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dunno what's going on there, or whether it's a fault or not.

dateAttr['month']

I can't get MSXML to return a node when accessed via ['_attribute_name_']
- although it does work in IE with custom HTML element attributes.

Any reason not to do this instead ..?:

trips[i].getElementsByTagName('date')[0].getAttribute('month')

// or

trips[i].getElementsByTagName('date')[0].getAttributeNode('month').nodeValue

chrisjoha

11:59 pm on Sep 10, 2005 (gmt 0)

10+ Year Member



No reason other than me not being Javascript compliant enough :) Thanks alot! Worked like a charm.