XML is basically a stricter version of HTML, so most of the work is already done and it shouldn't require too much refactoring
Parsing HTML is a quite common use case (like when scraping websites, parsing web pages, etc) but since the data is external we can't expect them to be exact html
Parsing html without requiring a full virtual dom library (like jsdom / happy-dom /linked-dom) would be quite nice for general use case, but also for tests validations when testing http documents serves
There are already precedent of having a more leniant parsing in other libs
- quick-xml (Rust): check_end_names(false)
- libxml2 XML_PARSE_RECOVER / lxml recover=True
- htmlparser2 and fast-xml-parser in the JS ecosystem
jsr:@libs/xml (which i maintain and like to rely on @std/xml now rather than a compiled wasm version of quick-xml)
What would be required:
- Supporting unquoted attribute values:
<root foo=bar> (value ends at whitespace, >, or /)
- Valueless attributes
<input disabled> (same as disabled="")
- Unclosed / mismatched elements:
</name> auto-closes intervening open elements (stray closing tags are ignored, elements still open at EOF are auto-closed instead of throwing)
- Duplicate attributes: first occurrence wins instead of throwing.
Btw the sync parse does not offer any way to recover the xml processing instructions nor the doctype atm
cc @tomas-zijdemans
XML is basically a stricter version of HTML, so most of the work is already done and it shouldn't require too much refactoring
Parsing HTML is a quite common use case (like when scraping websites, parsing web pages, etc) but since the data is external we can't expect them to be exact html
Parsing html without requiring a full virtual dom library (like jsdom / happy-dom /linked-dom) would be quite nice for general use case, but also for tests validations when testing http documents serves
There are already precedent of having a more leniant parsing in other libs
jsr:@libs/xml(which i maintain and like to rely on@std/xmlnow rather than a compiled wasm version of quick-xml)What would be required:
<root foo=bar>(value ends at whitespace,>, or/)<input disabled>(same asdisabled="")</name>auto-closes intervening open elements (stray closing tags are ignored, elements still open at EOF are auto-closed instead of throwing)Btw the sync parse does not offer any way to recover the xml processing instructions nor the doctype atm
cc @tomas-zijdemans