Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2005, 02:32 AM   PM User | #1
seilerk
New to the CF scene

 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
seilerk is an unknown quantity at this point
i cant parse the data in the subfields

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??
seilerk is offline   Reply With Quote
Old 03-24-2005, 02:56 PM   PM User | #2
codegoboom
Regular Coder

 
Join Date: Aug 2004
Location: codegoboom@yahoo.com
Posts: 999
Thanks: 0
Thanked 0 Times in 0 Posts
codegoboom is an unknown quantity at this point
Looks like it would depend on what the recordset method does. It might be easier to work with IE's "data binding" mechanism, where tables are concerned.

BTW, I hope that information isn't from a confidential medical record...
__________________
*this message will self destruct in n-seconds*
codegoboom is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:46 AM.


Advertisement
Log in to turn off these ads.