How do i access subchildren in XML via Spry

ageritith

New Member
I am able to access all the employee node info, but not the children of employee nodes. I hope this is making sense, I am probably using the wrong terms (new to XML and Java(Script)) but anyway I am including my code below. myhtmlfile.htm\[code\]<!DOCTYPE html> <html> <head> <script src="http://stackoverflow.com/questions/SpryAssets/xpath.js" type="text/javascript"></script> <script src="http://stackoverflow.com/questions/SpryAssets/SpryData.js" type="text/javascript"></script> <script type="text/javascript"> <!-- var employees=new Spry.Data.XMLDataSet("employee.xml", "employees/employee",{ sortOnLoad:"firstname", sortOrderOnLoad:"ascending"}); employees.setColumnType("boximage", "image"); //--> </script> </head> <body> <div id="employees"> <div spry:region="employees" id="empNames"> Click on Column Title to Sort by. <table width="475px"> <tr> <th spry:sort="firstname" align="right"><h3>First Name</h3></th> <th spry:sort="lastname" align="left"><h3>Last Name</h3></th> <th spry:sort="position "><h3>Job Title</h3></th> </tr> <tr spry:repeat="employees" spry:setrow="employees" spry:odd="oddRow" spry:even="evenRow" spry:hover="hoverRow" spry:select="selectRow"> <td align="right">{firstname}</td> <td>{lastname}</td> <td>{position}</td> </tr> </table> </div> <div id="empDetail" spry:detailregion="employees"><img src="http://stackoverflow.com/questions/11353051/{boximage}" alt="{firstname} {lastname}" title="{firstname} {lastname}" /><br /><span id="empName"><a href="http://stackoverflow.com/questions/11353051/{firstname}_{lastname}.htm">{firstname} {lastname}</a></span><br /> <span id="empPosition">{position}</span> <p>Section:<span id="empsection"> {section}</span><br /> Langauge: <span id="emplanguage">{language}</span><br /> Schedule: <span id="empSchedule">{schedule}</span></p> <p>Office Location: <span id="officename"><a href="http://stackoverflow.com/questions/{region}info.htm">{officename}</a></span><br /> Office Number: <span id="officeNumber">{officenumber}</span><br /> Cell Number: <span id="cellNumber">{cellnumber}</span><br /> Fax Number: <span id="faxNumber">{faxnumber}</span><br /> Email: <span id="email"><a href="mailto:{email}">{email}</a></span><br /> Supervisor: <span id="supervisor"><a href="http://stackoverflow.com/questions/11353051/{supervisorfname}_{supervisorlname}.htm">{supervisorfname} {supervisorlname}</a></span></p> <h2>Rotation History</h2> <table cellspacing="0" cellpadding="0" width="95%"> <tr> <td><h3>Location</td> <td><h3>Job Title</td> <td><h3>Date Start</td> <td><h3>Date End</td> <td><h3>Supervisor</td> <td><h3>Section</td> </tr> <tr> <td><a href="http://stackoverflow.com/questions/{region}info.htm">{$location}</a></td> <td>{JobTitle}</td> <td>{DateStart}</td> <td>{DateEnd}</td> <td><a href="http://stackoverflow.com/questions/11353051/{Supervisor}.htm">{Supervisor}</a></td> <td>{Section}</td> </tr> </table> <p>&nbsp;</p> </div> </div> </body> </html>\[/code\]You will notice if you run code in browser all data loads except for "Rotation History" due to being subchildren. Below is XML Data (shortened amount i.e not all entries but represents all element types)... employee.xml\[code\]<?xml version="1.0"?><employees> <employee> <firstname>Victor</firstname> <lastname>Kasu</lastname> <position>Principal Inspector</position> <officenumber>996</officenumber> <cellnumber>804</cellnumber> <faxnumber>477</faxnumber> <section>West</section> <language>spanish</language> <schedule>Off 1st Friday</schedule> <region>west</region> <officename>West Regional Office</officename> <officeaddress>1645</officeaddress> <officecity>Portland</officecity> <officestate>OR</officestate> <officezip>99784</officezip> <mailstop>9582</mailstop> <boximagelg>../images/staff/anlg.jpg</boximagelg> <boximage>../images/staff/ansm.jpg</boximage> <status>y</status> <supervisorfname>Sam</supervisorfname> <supervisorlname>Gill</supervisorlname> <email>[email protected]</email> <rotations> <location>Central</location> <JobTitle>Principal Inspector</JobTitle> <DateStart>1/1/2000</DateStart> <DateEnd>6/3/2012</DateEnd> <Supervisor>Malik Plum</Supervisor> <Section>Central</Section> </rotations> <rotations> <location>West</location> <JobTitle>Principal Inspector</JobTitle> <DateStart>6/4/2012</DateStart> <DateEnd>6/19/2012</DateEnd> <Supervisor>Sam Gill</Supervisor> <Section>West</Section> </rotations> </employee> <employee> <firstname>Malik</firstname> <lastname>Plum</lastname> <position>Chief (Retired)</position> <officenumber>213</officenumber> <cellnumber>213</cellnumber> <faxnumber>213</faxnumber> <section>Central/South</section> <language>none</language> <schedule>No RDO</schedule> <region>central</region> <officename>Central Regional Office</officename> <officeaddress>3550</officeaddress> <officecity>Denver</officecity> <officestate>CO</officestate> <officezip>24657</officezip> <mailstop>9581</mailstop> <boximagelg>../images/staff/lg.jpg</boximagelg> <boximage>../images/staff/sm.jpg</boximage> <status>n</status> <supervisorfname>Don</supervisorfname> <supervisorlname>Sauce</supervisorlname> <email>[email protected]</email> <rotations> <location>South Regional Office</location> <JobTitle>Senior</JobTitle> <DateStart>5/10/1997</DateStart> <DateEnd>2/17/2000</DateEnd> <Supervisor>Unknown</Supervisor> <Section>South</Section> </rotations> <rotations> <location>North Regional Office</location> <JobTitle>Principal</JobTitle> <DateStart>4/18/2007</DateStart> <DateEnd>5/15/2010</DateEnd> <Supervisor>Unknown</Supervisor> <Section>North</Section> </rotations> </employee> <employee> <firstname>Don</firstname> <lastname>Sauce</lastname> <position>Director</position> <officenumber>808</officenumber> <cellnumber>804</cellnumber> <faxnumber>555</faxnumber> <section>Code Division</section> <language>spanish</language> <schedule>No RDO</schedule> <region>garland</region> <officename>Garland</officename> <officeaddress>1200</officeaddress> <officecity>New York</officecity> <officestate>NY</officestate> <officezip>01234</officezip> <mailstop>958</mailstop> <boximagelg>../images/staff/lg.jpg</boximagelg> <boximage>../images/staff/sm.jpg</boximage> <status>y</status> <supervisorfname>Robert</supervisorfname> <supervisorlname>Alvin</supervisorlname> <email>[email protected]</email> <rotations> <location>South Regional Office</location> <JobTitle>Principal</JobTitle> <DateStart>5/10/1997</DateStart> <DateEnd>2/17/2000</DateEnd> <Supervisor>Unknown</Supervisor> <Section>South</Section> </rotations> <rotations> <location>North Regional Office</location> <JobTitle>Chief</JobTitle> <DateStart>2/18/2000</DateStart> <DateEnd>8/10/2011</DateEnd> <Supervisor>Unknown</Supervisor> <Section>North</Section> </rotations> </employee></employees>\[/code\]Sorry for a long post, but from reading other questions, wanted to give as much info as possible the 1st time. Ok, so again the problem I'm having is when calling all the other elements all works fine I have the table list and clicking on the name brings up the right info and such but when trying to access the subchildren data I get an error where data should show saying "undefined". I hope I have included all necessary info. PLEASE HELP. oh, I am using XML 1.0, Spry (region and detailregion), tried on both Firefox and IE 6-8, and using javascript. ok Any and ALL HELP MUCH Appreciated. THANKS.
 
Back
Top