954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Getting node name from xml file

Hey guys, is there a way to get a node's name and assign it as a value to a variable using javascript? Here's an example structure of the xml.

<list>
<student id="101">
<name>John Smith</name>
<DOB>07-09-1987</DOB>
<address>123 ABC street</address>
</student>

<student id="102">
<name>John Doe</name>
<DOB>05-04-1986</DOB>
<address>234 DEF street</address>
<address2>345 GHI street</address>
</list>


what I need to do is to check for student id with and input and create a table with the data, however, the fields of the 2 s are varied. I've figured out how to check for the id, however I'm clueless about getting the node names to place as the fields in the web page. My desired output should be:

=========|================
=name |John Smith =
==========================
=DOB |07-09-1987 =
==========================
=address |123 ABC street =
==========================

Is there a way to read , and tag names and then assign it to a variable called fields or the only way to do the fields column is to assign values to them manually?

Lyandor
Newbie Poster
17 posts since Jul 2011
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: