Open
Description
The same XML document behave differently in browser and with xmldom.
First, in browser (Firefox 75)
<script>
xml = '<?xml version="1.0" encoding="UTF-8"?>'
xml = xml + "\n<!DOCTYPE tag1 [\n"
xml = xml + "<!ENTITY hello \"hello1\">\n"
xml = xml + "<!ENTITY there \"there1\">\n"
xml = xml + "]>\n"
xml = xml + "<tag1>Stuff in &hello;</tag1>"
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xml, "text/xml");
alert(xmlDoc.doctype);
</script>
Result: [object DocumentType]
Then, the same XML document with xmldom
xml = '<?xml version="1.0" encoding="UTF-8"?>'
xml = xml + "\n<!DOCTYPE tag1 [\n"
xml = xml + "<!ENTITY hello \"hello1\">\n"
xml = xml + "<!ENTITY there \"there1\">\n"
xml = xml + "]>\n"
xml = xml + "<tag1>Stuff in here</tag1>"
var DOMParser = require('xmldom').DOMParser;
var doc = new DOMParser().parseFromString(xml);
console.info(doc.doctype);
Result: null
(the attribute doctype
does exist, its value is null
)
The document used in these examples:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tag1 [
<!ENTITY hello "hello1">
<!ENTITY there "there1">
]>
<tag1>Stuff in here</tag1>
Metadata
Assignees
Labels
No labels