renggli / dart-xml

Lightweight library for parsing, traversing, and transforming XML in Dart.
http://pub.dartlang.org/packages/xml
MIT License
223 stars 52 forks source link

Parse attribute without value #146

Closed CodeDoctorDE closed 1 year ago

CodeDoctorDE commented 2 years ago

I want to parse a html document but I get the error Unhandled Exception: XmlParserException: ">" expected at 17:140.

<script nonce="a" defer src="/core/js/oc.js?v=e23870b"></script>
renggli commented 2 years ago

defer is not a valid XML attribute.

Generally HTML documents cannot be parsed by an XML parser, as HTML has much more relaxed rules with regards to attributes and nesting/closing tags.

CodeDoctorDE commented 2 years ago

This is a pity. Do you have an alternative?

renggli commented 2 years ago

Parsing of incomplete attributes like in the above example could be supported. However dealing with HTML tags is very complicated.

I would look for a HTML parser, I think there is a Dart package that does that?