Comments (6)
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');
element parse error: TypeError: parseStack is undefined
@#[line:0,col:1]end tag name: my is not match the current start tagName:undefined
@#[line:1,col:2]============================================================
(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?
from xmldom.
More information about my troubles
This script:
load('dom.js');
load('dom-parser.js');
load('sax.js');
var doc = new DOMParser({
errorHandler:function(key,msg){
console.error(key, msg);
}
}).parseFromString('xml', 'text/xml');
Returns this under Rhino:
error element parse error: TypeError: Cannot read property "length" from undefined
@#[line:undefined,col:undefined]fatalError end tag name: some is not match the current start tagName:undefined
@#[line:undefined,col:undefined]Cannot read property "tagName" from undefined
And this under SpiderMonkey
error element parse error: TypeError: parseStack is undefined
@#[line:undefined,col:undefined]fatalError end tag name: some is not match the current start tagName:undefined
@#[line:undefined,col:undefined]============================================================
with this error stack:
Script engine error.
Place: 'Object::callFunction()'
ErrorReport:
13.16: TypeError: current is undefined
Error in 'dom-parser.js:113'
Stack:
((void 0),(void 0),"some")@dom-parser.js:113
parse("xml",[object Object],[object Object],[object Object],[object Object])@sax.js:107
("xml",[object Object],[object Object])@sax.js:31
("xml","text/xml")@dom-parser.js:25
test1()@dbc.js:22
@(interactive input):0
It would seem, that for some reason "parseStack" is not correctly set up.
Any clues from anyone?
from xmldom.
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:
https://github.com/jindw/xmldom/wiki/How-to-use-xmldom-in-non-node.js-JavaScript-platforms-like-Rhino-or-SpiderMonkey
from xmldom.
The workaround doesn't work in Nashorn.
I replaced loadObject with loadWithNewGlobal in the XMLDOM function, but then the dpObj will not load correctly,
var dpObj = loadWithNewGlobal(basePath + "/xmldom/dom-parser.js");
var dp_exports = {};
print('dpObj ' + dpObj + ', dp_exports ' + dp_exports);
prints
dpObj undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined, dp_exports [object Object]
but the dp_exports object seems to be empty.
from xmldom.
problems in running node.js
var doc = new dom().parseFromString(xml)
[xmldom error] element parse error: Error: invalid tagName:
@#[line:1,col:3]
[xmldom error] element parse error: Error: invalid tagName:
@#[line:13,col:2]
[xmldom error] element parse error: Error: invalid tagName:
@#[line:15,col:2]
[xmldom error] element parse error: Error: invalid tagName:
@#[line:17,col:2]
[xmldom error] element parse error: Error: invalid tagName:
...
the xml string is from an html file generated from an email
thanks for the help.
Love and peace,
Joew
from xmldom.
@JoeCodeswell make sure that you have the file in the correct encoding (Most likely UTF-8)
from xmldom.
Related Issues (20)
- No errors reported for missing XML entities with periods HOT 1
- parsing > back and forth HOT 1
- Is this project even active anymore? HOT 2
- Namespace propagation is not correct on serialization HOT 4
- License Info HOT 6
- Out of memory error while parsing large string HOT 1
- Could I get it without require ? HOT 1
- Repo Dead - Alternatives
- Wrong format after InsertBefore
- FYI: This project has been hard forked HOT 1
- doctype returns null
- parseFromString() ignore all the content before first <br/>
- Non existent 'java' attempted to be used in xmldom.
- License tests and copyright notice missing
- How to find the nodes within a file
- Correct encode text
- invalid attribute::model HOT 5
- Update the README to point to the fork????? HOT 1
- serializer options HOT 2
- Great code HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xmldom.