Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •