dart-xml icon indicating copy to clipboard operation
dart-xml copied to clipboard

Parse attribute without value

Open CodeDoctorDE opened this issue 2 years ago • 3 comments

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>

CodeDoctorDE avatar Jun 20 '22 17:06 CodeDoctorDE

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.

renggli avatar Jun 20 '22 18:06 renggli

This is a pity. Do you have an alternative?

CodeDoctorDE avatar Jun 20 '22 18:06 CodeDoctorDE

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?

renggli avatar Jun 20 '22 18:06 renggli