Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doctype returns null #260

Open
SmartLayer opened this issue Apr 15, 2020 · 0 comments
Open

doctype returns null #260

SmartLayer opened this issue Apr 15, 2020 · 0 comments

Comments

@SmartLayer
Copy link

SmartLayer commented Apr 15, 2020

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant