-
Notifications
You must be signed in to change notification settings - Fork 607
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
Error: Text data outside of root node. #255
Comments
Can you provide a sample snippet that repos this issue? |
Also having this issue. I have some malformed XML coming in via a stream, and this exception is thrown every so often. Is there anyway to handle the error rather than allowing it to crash my app? The relevant exception returns the following message: When exiting: err passed in the callback Was also under the impression this was previously solved. |
@compkidchris and @cubesapp, we need sample code to replicate the issue |
A more verbose error would be:
The XML here is split across multiple calls to the parser, each snippet following "Offending XML: " is what is passed to the parser, Purported Error is the err from the parseString callback. The Final Error is the error/exception that ends my app. Let me know if this is helpful, I can provide some simple code which exemplifies this issue if need be. Edit: Don't know how to format for code, there are tags where there are Offending XML. |
@compkidchris, am I understanding this correctly? You are streaming an XML document and are trying to parse it with each chunk you receive? If that assumption is correct then change your workflow to parse after all chunks are gathered. |
Will do, not sure if @cubesapp has another issue entirely though. |
I haven't been able to reproduce the issue lately. So I don't have the xml and code snippet yet! We have made code changes on our end recently to ensure that MOST XML documents being passed to parseString are valid. Sending partial XML documents via stream to parseString seems to be the issue (which we were doing). Ideally, if parseString returns an error instead of throwing an exception would be best; in order to handle this issue. |
@cubesapp I just want to reiterate that
I don't understand what you mean by returns an error. |
I always assumed that the call was async. So in the following: var parser = new xml2js.Parser(); Would I wrap it in an a try/catch? If this is the case, thanks and I am good to go with this. |
I guess this can be closed... |
I am getting an exception thrown with the latest release v0.4.15. Obviously the xml being passed is badly formed. To my understanding this was fixed in #118
var parser = new xml2js.Parser();
parser.parseString(data,function(err, result) {
// do something;
});
The text was updated successfully, but these errors were encountered: