Open jyywhw opened 7 years ago
Try assigning errorHandlers when you initialize the DOMParser.
I use a generic wrapper function that looks like this:
function xmldomWithParseError(xmlString){
// throw exception for any parsing errors or warnings
var errorHandler = function(errorString){
throw new Error(errorString);
}
// let's throw Exceptions when W3C/node-xmldom XMLParser.parseFromString() encounters any warnings or errors
var domOptions = {
errorHandler: {
warning: errorHandler,
error: errorHandler,
fatalError: errorHandler
},
locator: {}
};
var xmldom = new XmlDom.DOMParser(domOptions).parseFromString(xmlString, 'text/xml');
return xmldom;
}
I use an xml string like "xxx</b" to test xmldom, which can't show error message for it, but just pass this xml parsed.
How do I use xmldom to make it show error message?