Comments (3)
Hi, I have the same issue.
I was able to track it and found where it comes from. It seems that the firefox
DOM parser does like this code:
try {
parsererrorNS = parser.parseFromString("INVALID", "text/xml").childNodes[0].namespaceURI;
}
catch(err) {
parsererrorNS = null;
}
When trying to parse the INVALID string, firefox DOM parser shows this "syntax
error" on HTML line 1 in the console, event if the conversion error is
surrounded by try-catch.
Original comment by [email protected]
on 20 Feb 2015 at 7:37
from x2js.
Same here. Weird thing is that it works in Chrome perfectly. The XML seems also
to be OK. But it always fails in Firefox within the try-catch block posted
above.
Original comment by [email protected]
on 27 Mar 2015 at 1:45
from x2js.
I think the code is trying to solve the fact that some browsers include the
parsererror element in another namespace (eg:
http://stackoverflow.com/questions/11563554/how-do-i-detect-xml-parsing-errors-w
hen-using-javascripts-domparser-in-a-cross).
It parses an invalid xml to get the possible namespace for the parsererror
element.
What I think would be a better solution (altough I don't know if it will work
for all browsers) is to eliminate this check and use a wildcard to get all
parsererror elements independent of the namespace.
The patch below show the changes I have made and it has worked for me:
@@ -489,21 +489,9 @@
var xmlDoc;
if (window.DOMParser) {
var parser=new window.DOMParser();
- var parsererrorNS = null;
- // IE9+ now is here
- if(!isIEParser) {
- try {
- parsererrorNS = parser.parseFromString("<",
"text/xml").childNodes[0].namespaceURI;
- console.log(parsererrorNS);
- }
- catch(err) {
- console.log('error:' + err);
- parsererrorNS = null;
- }
- }
try {
xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
- if( parsererrorNS!= null && xmlDoc.getElementsByTagNameNS(parsererrorNS,
"parsererror").length > 0) {
+ if(xmlDoc.getElementsByTagNameNS("*", "parsererror").length > 0) {
//throw new Error('Error parsing XML: '+xmlDocStr);
xmlDoc = null;
}
Original comment by [email protected]
on 2 Jun 2015 at 10:27
from x2js.
Related Issues (20)
- trim() in IE8 HOT 2
- IE9 DOM Exception HOT 6
- namespace url does not properly convert from json to xml HOT 3
- Decode problem in Firefox v30 and IE10 HOT 8
- asArray(undefined) == [undefined] HOT 4
- ReferenceError: "ActiveXObject" is not defined error thrown HOT 6
- Option to use double quotations for XML attribute values HOT 2
- can't use escaped characters HOT 2
- namespaces not working in chrome HOT 2
- 'Not enough storage is available to complete this operation' occurs in IE when parsing long XML string
- Set a null prefix HOT 3
- Problems when having ':' in XML attribute names HOT 5
- ape HOT 1
- Namespaces stripped from elements but not attributes HOT 1
- Request: Ignoring invalid XML element names from object properties HOT 3
- / is escaped but should NOT be escaped HOT 2
- escape "&" caractere HOT 1
- official github repo HOT 1
- unable to run published demo 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 x2js.