/    Sign up×
Community /Pin to ProfileBookmark

cannot get data from subfields using javascript

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??

to post a comment
Full-stack Developer

1 Comments(s)

Copy linkTweet thisAlerts:
@rhsundergroundMar 24.2005 — no need to [URL=http://www.webdeveloper.com/forum/showthread.php?s=&threadid=60538]double post[/URL]? ?
×

Success!

Help @seilerk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...