-
Notifications
You must be signed in to change notification settings - Fork 265
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
Cannot get code working #88
Comments
The string 123, is not actually valid XML though. But, I have the same problem here for actual valid XML: var doc = parser.parseFromString('xml', 'text/xml'); (This is loading the modules in either SpiderMonkey or Rhino, not in node.js - I have no idea how to load the current head in node.js). Is there a mailing list for this project? |
More information about my troubles This script:load('dom.js'); var doc = new DOMParser({ Returns this under Rhino:error element parse error: TypeError: Cannot read property "length" from undefined And this under SpiderMonkeyerror element parse error: TypeError: parseStack is undefined Stack: It would seem, that for some reason "parseStack" is not correctly set up. Any clues from anyone? |
OK, I digged a bit further into it. It turns out, that you need to encapsulate each file when loading them. I was led by the conditional support of node.js (based on the presence of a require function) to think that you could just load them, and use them. I think that is not actually possibly in the current form: both the file sax.js and the file dom-parser.js declares a global method called appendElement. No matter which order you load them in, one will overwrite the other, and you will get problems. The error we see here, is because the sax file is loaded last. When its "appendElement" function is called, it will call stuff on the domBuilder, and the domBuilder will try to call its appendElement function, which takes two elements, but will hit the appendElement of the sax.js file, which requires three elements. The last argument is the parseStack, and it will be undefined, and the error comes from that. I have added some information about how to fix this problem to the wiki, here: |
The workaround doesn't work in Nashorn. I replaced loadObject with loadWithNewGlobal in the XMLDOM function, but then the dpObj will not load correctly,
prints
but the dp_exports object seems to be empty. |
problems in running node.js
... the xml string is from an html file generated from an email thanks for the help. |
@JoeCodeswell make sure that you have the file in the correct encoding (Most likely UTF-8) |
The simple string is falled to exception
var string="123"
console.log((new DOMParser()).parseFromString(string, "text/xml"));
error "end tag name: root is not match the current start tagName:undefined"
The text was updated successfully, but these errors were encountered: