Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to use responseXML to parse xml

843838Jan 31 2007 — edited Oct 29 2008
Hi,

I am sending this xml from server
<assignmentList>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>0</listenerClass>
</assignment>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>1</listenerClass>
</assignment>
</assignmentList>

I need to parse above xml to get id , name,fileclass etc

but in my js
var root = o.responseXML.documentElement;
var length=root.getElementsByTagName('assignment").length;
alert(length); // displays 0.

I need to get the length and iterate to get values from above two tags.
But could not achieve it.




but when I send

<assignmentList>
<assignment>
<id>333</id><name>1170235257994</name><fileClass>4</fileClass><checked_out_by> </checked_out_by><status>s1</status><publication>p1</publication><section>s1</section><change_type>1</change_type><listenerClass>0</listenerClass>
</assignment>
</assignmentList>

alert(length); // displays 1. correct


Can you please show me how I can get correct length and then get values from it
by getting values I mean

var assetId = root.getElementsByTagName('id').firstChild.nodeValue;

currently not working.


waiting for response


thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2008
Added on Jan 31 2007
5 comments
281 views