I was wondering if there is a way to parse pure XML documents, such
that methods like tagName return non-normalized, case-sensitive
results. I have tried the following:
var jsdom = require("jsdom").jsdom;
var document = jsdom("<test><foo></foo></test>");
But this has the following problems:
1. does not populate document.documentElement
2. DOM nodes can be retrieved using document.getElementsByTagName,
e.g. var foo = document.getElementsByTagName("foo")[0];. But in this
case, foo.tagName will return the tag name normalized to uppercase,
e.g. "FOO".
I have also tried using jsdom.env, and the result is the same except
that the DOM nodes from the parsed input string are wrapped in
"<html><body>" tags.
I would try the technique of creating a new document using the
following API:
var doc = new (jsdom.dom.level3.core.Document)();
But, I cannot figure out how to use this API to parse an XML string. I
have looked at the source code, and I see in example/node-xml there is
a test that shows DOM parsing using this jsdom document creation API
in conjunction with the node-xml SAX library in order to parse an XML
document into jsdom DOM structures, but I would rather just use jsdom
for parsing, if possible.
I have spent a few hours on this and have not been able to find the
answer. I would appreciate any guidance anyone can offer. Thanks,
Jake