blob84 Posted March 29, 2010 Share Posted March 29, 2010 Hi all,when i use this code i get undefined: <?xml version="1.0" ?><message id="1"><user>john</user></message><script type="text/javascript">alert(document.getElementsByTagName('message')[0].id);</script> Link to comment Share on other sites More sharing options...
boen_robot Posted March 29, 2010 Share Posted March 29, 2010 First stop, are you sure you're gointing at the right document? The "document" object points to the current (HTML) document, not an external XML document.Second, if this is XML, you'll have to get the attribute with the getAttribute() method, like: getElementsByTagName('message')[0].getAttribute("id") Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.