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

Better handle XML parsing issues #150

Open
supersonicclay opened this issue Oct 1, 2018 · 0 comments
Open

Better handle XML parsing issues #150

supersonicclay opened this issue Oct 1, 2018 · 0 comments

Comments

@supersonicclay
Copy link

supersonicclay commented Oct 1, 2018

Repro

const xml = new DOMParser().parseFromString('<abc>', 'text/xml');
try {
  const geojson = togeojson(xml);
  console.log(geojson);
} catch (err) {
  console.error(err)
}

Actual result

{ type: 'FeatureCollection', features: [] }

Expected result

Exception thrown with error speaking to the fact that the XML is bad.

Ideas for solution

var d = new DOMParser().parseFromString('<foo>bar</foop><foot gun</foot>', 'text/xml');
Array.from(d.querySelectorAll('parsererror > div')).forEach(err => console.log(err.innerText));

Outputs: error on line 1 at column 19: Opening and ending tag mismatch: foo line 0 and foop

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

No branches or pull requests

1 participant