Closed
Bug 295567
Opened 20 years ago
Closed 20 years ago
getElementById() looks broken for XML documents
Categories
(Core :: XML, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: surkov, Unassigned)
Details
Attachments
(3 files)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; ru-RU; rv:1.7.5) Gecko/20041108 Firefox/1.0 (ax)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b) Gecko/20050217
When I specify arbitrary namespace to XML document (not xul of html namespace)
then getElementById() returns null.
In instance:
var xmlwnd=window.open(xmlurl);
window.setTimeout(function()
{
alert(xmlwnd.document.getElementById('user'));
},
0);
or if I load XML document by XMLHttpRequest object then I get the same result.
requestor=new XMLHttpRequest();
requestor.open("get", url, false);
requestor.send(null);
var xmldoc=requestor.responseXML;
alert(xmldoc.getElementById('user'));
Reproducible: Always
Comment 1•20 years ago
|
||
Since you haven't included a testcase, I'm going to guess that you haven't defined the ID in the DTD, which you need to do for arbitrary XML.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 2•20 years ago
|
||
Yes. I didn't use DTD for my XML file. Can you provide a link on such XML file with DTD?
| Reporter | ||
Comment 3•20 years ago
|
||
| Reporter | ||
Comment 4•20 years ago
|
||
| Reporter | ||
Comment 5•20 years ago
|
||
save xml, dtd and xul files at root of local disc C: and run xul file. getElementById() returns null. What is wrong?
Comment 6•20 years ago
|
||
Your DTD is broken. Use an XML validator to check (for example http://www.stg.brown.edu/service/xmlvalid/).
| Reporter | ||
Comment 7•20 years ago
|
||
Is there a way to attach external DTD (stored in individual file) to xml file by file or http protocol? If I can load external DTD by chrome protocol only then why?
| Reporter | ||
Updated•20 years ago
|
Status: RESOLVED → VERIFIED
(In reply to comment #7) > Is there a way to attach external DTD (stored in individual file) to xml file by > file or http protocol? If I can load external DTD by chrome protocol only then why? Mozilla does not support loading external DTDs from remote sites. You should put a small DOCTYPE section in the beginning of all your XML documents. For example: <!DOCTYPE foo [ <!ATTLIST abc myid ID #IMPLIED> ]> <foo> <abc myid="someid">I can getElementById() this!</abc> <script xmlns="http://www.w3.org/1999/xhtml">alert(document.getElementById("someid").firstChild.nodeValue);</script> </foo>
You need to log in
before you can comment on or make changes to this bug.
Description
•