How to prevent Dart xml package to decode entity?

Viewed 67

Having the following xml file :

<sense>
<pos>&int;</pos>
</sense>

The following code :

import 'dart:io';
import 'package:xml/xml.dart' as xml;

void main() {
  File('data/sense.xml').readAsString().then((String contents) {   
    xml.XmlDocument document = xml.parse(contents);
    xml.XmlElement sense = document.findAllElements('sense').first;
    print(sense.toString());
  });
}

will output

<sense>
<pos>∫</pos>
</sense>

Are there any option to prevent the entity &int; to be decoded to ?

1 Answers

Customizing the decoded entities is not currently supported by the library. I suggest that you file a feature request at https://github.com/renggli/dart-xml.

As a workaround you could wrap your entities in CDATA tokens, so that your input would look like:

<sense>
<pos><![CDATA[&int;]]></pos>
</sense>
Related