我正在使用标准DOMParser()(在XML解析器中构建的浏览器)在JS中创建XMLDocument-Object。这非常有用,但是doctype.entities NodeMap保持为空,即使它在XML文档中设置正确。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tag1 [
<!ENTITY hello "hello1">
<!ENTITY there "there1">
]>
<tag1>Stuff in here</tag1>
JS函数看起来像这样:
function(xmlString)
{
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlString, "text/xml");
var docEntities = xmlDoc.doctype.entities;
//Do stuff with the docEntities
}
docEntities定义为具有实体的NodeMap,但即使xmlDoc.doctype是DocumentType-Object,也未定义。 为什么Parser不这样做?