cannot get data from the subfields

admin

Administrator
Staff member
I am having a problem with writing a parser in javascript. I have a xml file that has data the looks like this:

<patients>
<patient age="20">
<first_name>Keith</first_name>
<middle_name>John</middle_name>
<last_name>Griffey</last_name>
<ssn>267-81-8362</ssn>
<room>231</room>
<insurance>
<com_name>anthem</com_name>
<mem_id>KY</mem_id>
<group>none</group>
<phone_num>812-584-2162</phone_num>
</insurance>
</patient>
</patients>


My DTD file :

<!ELEMENT patients (patient+) >
<!ELEMENT patient (first_name,middle_name ,last_name,ssn,room,insurance )>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT middle_name (#PCDATA)>
<!ELEMENT last_name (#PCDATA)>
<!ELEMENT ssn (#PCDATA)>
<!ELEMENT room (#PCDATA)>
<!ELEMENT insurance (com_name,mem_id,group,phone_num)>
<!ELEMENT com_name (#PCDATA)>
<!ELEMENT mem_id (#PCDATA)>
<!ELEMENT group (#PCDATA)>
<!ELEMENT phone_num (#PCDATA)>


<!ATTLIST patient age CDATA #REQUIRED>


for some reason i can not access the data in insurance to parse the data. insurance has 4 subfields in it but im not sure how to access it. my JS code looks like this:

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("hospital2.xml");
var doc=xmlDoc.documentElement;

function testclick(field)
{
var row=field.rowIndex
xml_list.recordset.absoluteposition=row
td_first.innerHTML=xml_list.recordset("first_name")
td_middle.innerHTML=xml_list.recordset("middle_name")
td_last.innerHTML=xml_list.recordset("last_name")
td_ssn.innerHTML=xml_list.recordset("ssn")
td_age.innerHTML=xml_list.recordset("age")
td_room.innerHTML=xml_list.recordset("room")
//td_insurance.innerHTML=xml_list.recordset("insurance") // problem starts here
td_com_name.innerHTML.innerHTML=xml_list.recordset("com_name")
td_mem_id.innerHTML=xml_list.recordset("mem_id")
td_group.innerHTML=xml_list.recordset("group")
td_phone.innerHTML=xml_list.recordset("phone_num")
}

it will read the data all the way to the recordlist "room" but throws an error after that because of the subfields in insurance. can anyone help??
 
Back
Top