I’m trying to get getElementById to work with an XML structure. In this case, I am creating web pages based on two xml files: positions and personnel. I create a logical link between them by using a modified “person’s name” (with bl
anks replaced by underscores and apostrophes & periods removed) as the incumbent in the position file. The same thing is set as an id attribute in the personnel file.
The dtd for the personnel file is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE people [
<!ELEMENT person (name, email?, bio, telephone*)>
<!ATTLIST person id ID #REQUIRED >
<!ELEMENT name (#PCDATA)>
<!ELEMENT email (email-name, email-domain)>
<!ELEMENT email-name (#PCDATA)>
<!ELEMENT email-domain (#PCDATA)>
<!ELEMENT bio (photo, p*, li*)>
<!ELEMENT photo (#PCDATA)>
<!ELEMENT p (#PCDATA)>
<!ELEMENT li (#PCDATA)>
<!ELEMENT telephone (tel-type, tel-area, tel-num, tel-ext?)>
<!ELEMENT tel-type (#PCDATA)>
<!ELEMENT tel-area (#PCDATA)>
<!ELEMENT tel-num (#PCDATA)>
<!ELEMENT tel-ext (#PCDATA)>
]>
The data gets loaded into peopleList but
var incumbentDetails = peopleList.getElementById(curIncumbent);
fails. I’ve verified that curIncumbent contains the correct (and valid) information and checked for duplicate ids (there aren’t any). I’ve verified that I’ve loaded the correct number of “person” elements.
What I haven’t found in my searching is a sample DTD that actually shows an ID attribute in a full defined DTD. I suspect the issue may be in the DTD but it’s hard to tell if I’m making progress when the function only fails.
Any help would be appreciated.