This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi, If you look here: api/org/w3c/dom/Document.html#getElementById(java.lang.String) It says : "The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null."
So how do I "define so.."?
Because the only reason it returns null is because of this. My document has only 1 node with attribute ID = "the name".
Thanks. [ December 09, 2008: Message edited by: John Landon ]
You have to create a schema, or a DTD, which declares that "id" attribute to be of ID type. (Sorry, I don't know how to do that.) And when parsing the document, you have to make sure you validate it against that schema or DTD.
If that seems like a lot of trouble you could just replace that code by a call to something that applies the equivalent XPath expression.