dlang-community / experimental.xml

A replacement of Phobos std.xml
https://rawgit.com/dlang-community/experimental.xml/gh-pages/index.html
Boost Software License 1.0
11 stars 8 forks source link

Parse XML files without xml declaration #12

Open wilzbach opened 6 years ago

wilzbach commented 6 years ago

From @Ingrater on November 2, 2016 15:40

First off: Awesome project. Please keep going and get it merged into phobos!

In the wild its quite common to have files which use xml syntax but don't have a xml declaration: <?xml version="1.0" encoding="UTF-8"?>

It should be easy to parse such files. My current workaround is to manually stick a xml declaration to the front of the buffer before parsing it.

Copied from original issue: lodo1995/experimental.xml#36

wilzbach commented 6 years ago

From @lodo1995 on November 2, 2016 17:13

Thank you for your appreciation. I'm currently very busy, but I'm trying to find some time to go ahead with this project, because it really deserves to be pushed.

You should be able to set a custom error handler when creating the cursor. Inside this handler, you can decide to ignore errors triggered by missing XML declarations, while throwing an exception (or doing whatever you want) in case of any other problem.