- Add support for most XPath 1.0 functions, including set-operations and ensuring document order for node-sets.
- Add support for XPath expression evaluation, user-defined variables, and user-defined functions.
- Add
XmlNode.xpathGenerate
to create a readable XPath for all nodes. - Add support for node comparison:
XmlNode.isEqualNode
andXmlNode.compareNodePosition
.
- Dart 3.0 and PetitParser 6.0 requirement.
- Add RSS feed reader example.
- Upgrade to Dart 2.19 and PetitParser 5.4.
- Add
XmlElement.tag
constructor that greatly simplifies the creation of elements, i.e.XmlElement(XmlName('br'), [], [], true)
becomesXmlElement.tag('br', isSelfClosing: true)
. - Deprecate the ambiguous
XmlNode.text
: Replace withXmlNode.value
to access the textual contents of the node, orXmlNode.innerText
to access the textual contents of its descendants. - Fix
XmlNode.siblings
and various related methods to also work correctly onXmlAttribute
nodes, make the method return a mutable list. - Improve
XmlNode.replace(XmlNode)
and addXmlNode.remove()
for easy removal of a node. - Improve error position propagation when building the XML DOM.
- Make the parser more forgiving when reading attributes.
- Experimental support of a subset of XPath.
- Add new-line normalization support.
- Upgrade to PetitParser 5.1 brings a 10% speed improvement (typed sequences).
- Add the ability to tap into a stream of
XmlEvent
withtapEachEvent
(similar toforEachEvent
). - Remove
XmlName
equality operator==
andhashCode
. This is inconsistent with the other DOM nodes, and the provided implementation might not have the desired behavior. - Improved error reporting when accessing
innerText
orinnerXml
on DOM nodes that cannot have children.
- Dart 2.17 requirement.
- Validate the presence and order of root nodes when parsing; this got lost in 6.0.0 and can now also optionally be enabled for streaming and iterable parsers.
- Add support for basic document type parsing. The contents of the
XmlDoctype
can now be accessed throughname
,externalId
andinternalSubset
.
- Significantly improve parsing performance by up to 30%.
- Improved error handling to include more information, such as tag names and location in the parsed source.
- Use the pull-based parser for all underlying parsing operations:
- Reduce size of library by removing duplicated parsing and validation functionality.
- Fix entity decoding if the entity spawns multiple chunks.
- Cleanup dynamic calls and type declarations:
- Avoid all dynamic calls across the library (thanks to srawlins).
- Remove deprecated
XmlTransformer
as it requires dynamic calls in theXmlVisitor
. - Cleanup the dynamic typing of
XmlVisitor
.
XmlBuilder
keeps keeps correct nesting, even in case of exceptions.- Remove deprecated code:
parse(String input)
: useXmlDocument.parse(String input)
orXmlDocumentFragment.parse(String input)
instead.XmlBuilder.build()
: useXmlBuilder.buildDocument()
orXmlBuilder.buildFragment()
instead.XmlNormalizer.defaultInstance
: useconst XmlNormalizer()
instead.XmlProductionDefinition
,XmlGrammarDefinition
, andXmlParserDefinition
.
- Dart 2.16 requirement.
- Update to PetitParser 5.0.
- Escape control characters (thanks to rspilker).
- Add a predicate to pretty printer to insert a space character before self-closing elements (thanks to rspilker).
- Add predicates to normalizer to trim leading and trailing whitespaces, as well as collapse consecutive whitespaces.
- Expose
qualifiedName
,localName
,namespacePrefix
andnamespaceUri
for convenience on the named nodes.
- Dart 2.15 requirement.
- Upgrade to PetitParser 4.3.
- A series of read-only accessors that simplify navigating the XML DOM with
XmlElements
:- Add
XmlNode.childElements
. - Add
XmlNode.siblings
andXmlNode.siblingElements
. - Add
XmlNode.previousElementSibling
andXmlNode.nextElementSibling
. - Add
XmlNode.ancestorElements
,XmlNode.precedingElements
,XmlNode.descendantElements
, andXmlNode.followingElements
.
- Add
- Fix printing of Exceptions.
- Fix parsing of DOCTYPE tags.
- Upgrade to PetitParser 4.1.0.
- Dart 2.12 requirement and null-safety.
- Add the possibility to
XmlBuilder
to add raw strings. - Improve error reporting (particularly for fragment parsing).
- Default entity mapping is now a global setting.
- Improve tutorials and documentation.
- Fixed a bug in the XML name parsing where certain unicode planes were not correctly recognized.
- Removed const constructor from
XmlEvent
to be able to add a lazy initializedparentEvent
field. - Add
XmlWithParentEvents
that provides validation of event nesting and efficient access to the parent events. Usestream.withParentEvents()
to annotate the stream accordingly. - Add namespace resolution to events through
event.namespaceUri
. Note that the data is only available when the parent information is present (see above). - Fix namespace resolutions for events in selected sub-tree nodes, even if the namespace declaration is not part of the visible DOM.
- Add
stream.forEachEvent(onText: ...)
for easier callback based stream processing.
- Add a
XmlSubtreeSelector
that allows efficient filtering of events in specific sub-trees. Usestream.selectSubtreeEvents(...)
to filter the stream accordingly. - Add more options to XML pretty printer, namely the possibility to sort and indent attributes.
- Add typed extension methods for all stream converters, for simpler and more fluent API.
- Improvements to documentation and examples.
- Improve error reporting of
XmlBuilder
and add possibility to buildXmlDocumentFragments
. - Improvements to documentation and examples.
- Deprecate standalone
XmlDocument parse(String input)
method, and introduce factory methods in the respective nodesXmlDocument.parse(String input)
andXmlDocumentFragment.parse(String input)
. - Introduce getters and setters for
XmlNode.innerText
(in most cases an alias toXmlNode.text
),XmlNode.innerXml
andXmlNode.outerXml
. - Improved support for
XmlDocumentFragment
across the library. - Remove the
XmlDocument.text
override, which returnednull
. - Add
XmlNode.replace(XmlNode other)
to make it easier to replace nodes in an existing tree. - Add
XmlNode.getElement(String name)
as a shortcut to find the first child element with a given name. - Add
XmlNode.firstElementChild
andXmlNode.lastElementChild
to easy access the first/last child element. - Add support to selectively disable whitespace normalization while pretty-printing, for example
document.toXmlString(pretty: true, preserveWhitespace: (node) => node is XmlElement && node.name.local == 'pre')
would keep everything within<pre>
tags as-is.
- Improve the pretty printing and the customization of the pretty printing:
XmlWriter
andXmlPrettyWriter
are now initialized with optional arguments.- Pretty printing now also supports to customize the newline support.
- Example is updated to also syntax highlight / colorize the output.
- Add full namespace support to attribute accessors
setAttribute
andremoveAttribute
. - Improved the documentation, particularly started a section on
xml_events
package.
- Cleanup the node hierarchy. Specifically removed
XmlOwned
andXmlParent
that added a lot of complexity and confusion. Instead, introduced dedicated mixins for nodes with attributes (XmlHasAttributes
), children (XmlHasChildren
), names (XmlHasName
) or parents (XmlHasParent
). - Introduce
XmlDeclaration
nodes, events and builder to make accessing XML version and encoding simpler.
- Update to PetitParser 3.0.0.
- Dart 2.7 compatibility and requirement.
- Entity decoding and encoding is now configurable with an
XmlEntityMapping
. All operations that read or write XML can now (optionally) be configured with an entity mapper. - The default entity mapping used only maps XML entities, as opposed to all HTML entities as in
previous versions. To get the old behavior use
XmlDefaultEntityMapping.html5
. - Made
XmlParserError
aFormatException
to follow typical Dart exception style. - Add an example demonstrating the interaction with HTTP APIs.
- Dart 2.3 compatibility and requirement.
- Turn various abstract classes into proper mixins.
- Numerous documentation improvements and code optimizations.
- Add an event parser example.
- Dart 2.2 compatibility and requirement.
- Take advantage of PetitParser fast-parse mode:
- 15-30% faster DOM parsing, and
- 15-50% faster event parsing.
- Improve error messages and reporting.
- New events based parsing in
xml_events
:- Lazy event parsing from an XML string into an
Iterable
ofXmlEvent
. - Async converters between streams of XML,
XmlEvent
andXmlNode
.
- Lazy event parsing from an XML string into an
- Clean up package structure by moving internal packages into the
src/
subtree. - Remove the experimental SAX parser, the event parser allows more flexible streaming XML consumption.
- Remove unnecessary whitespace when printing self-closing tags.
- Remember if an element is self-closing for stable printing.
- Migrated to PetitParser 2.0
- Drop Dart 1.0 compatibility
- Cleanup, optimization and improved documentation
- Add experimental support for SAX parsing
- Mutable DOM
- Cleaned up documentation
- Dart 2.0 strong mode compatibility
- Reformatted using dartfmt
- Fix CDATA encoding
- Migrate to micro libraries
- Fixed linter issues
- Generic Method syntax with Dart 1.21
- Do no longer use
ArgumentError
, but instead use proper exceptions.
- Fixed attribute escaping
- Preserve single and double quotes
- Improved documentation
- Use enum as the node type
- Fixed attribute escaping
- Fixed linter issues
- Cleanup node hierarchy
- Improved documentation
- Improved test coverage
- Improved comments
- Optimize namespaces
- Formatted source
- Cleanup pretty printing
- Improved comments