Skip to content
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

Parse xml responses files as xml files #209

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

samogot
Copy link
Contributor

@samogot samogot commented May 12, 2018

For example it fixes interpretation of opening tag in RSS as HTML
inline tag without text content.

Also allow to overwrite parsing method.

Fixes #204

@rchipka
Copy link
Owner

rchipka commented May 12, 2018

@samogot Can you add a test?

parse_mode = getResponseType(res.headers['content-type']);
try {
if (parse_mode === 'xml')
document = libxml.parseXml(document, {baseUrl: location.href, huge: true});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, was it always throwing on parse errors or is this new with parseXml?

Can you try adding the XML parse option errors: false so we can avoid the try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libxmljs docs says that unrecoverable errors are "thrown and need to be caught". I don't know is there any fatal errors in html mode, though. But anyway using try-catch even for html is safer, just in case. Why don't you like it?

Xml throws even with errors: false. Looks like this option is only about recoverable errors.

For example it fixes interpretation of opening <link> tag in RSS as HTML
inline tag <link /> without text content.

Also allow to overwrite parsing method.
Xml parsing is more strict and have more unrecoverable errors like
absence of root element or multiply root elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XML not working
2 participants