KirillOsenkov / XmlParser

A Roslyn-inspired full-fidelity XML parser with no dependencies and a simple Visual Studio XML language service
Apache License 2.0
328 stars 49 forks source link

Save valid XML #40

Open Geograph-us opened 2 years ago

Geograph-us commented 2 years ago

XmlParser can open invalid or broken XML-files. Is it possible to save it as valid XML-file?

KirillOsenkov commented 2 years ago

not currently, I imagine one would need logic to write missing tokens and skip skipped tokens

michael-hawker commented 10 months ago

A while back I was trying to figure out how to use the API for this scenario as well: https://github.com/michael-hawker/XmlSyntaxVisualizerUWP/blob/e8f28aa8487a69627b25c8d76a8230d1f5270e7a/XmlParserHelpers.cs

Didn't realize the tree was immutable at first, so was only getting part of it back; though my approach is working better here than remember. Seems like I may want to look for valid trees within the invalid one to re-attach higher to save more 'valid' content.

@KirillOsenkov any tips/advice for easier APIs/approaches with the existing API set would be great.

KirillOsenkov commented 10 months ago

Unfortunately I don't have much to offer you, if you have looked at this you probably already know more than me about this!