readXmlValue<T> method

  1. @override
T readXmlValue<T>(
  1. String xml,
  2. Class<T> type
)
override

Deserializes an XML string into an object of type T.

The XML is parsed into an intermediate XmlNode tree, which is then mapped to a Dart object using reflection and configured converters.

Example

final user = mapper.readXmlValue<User>(
  '<user><id>1</id><name>Alice</name></user>',
  Class<User>()
);

Error Handling

Throws an exception if:

  • The XML is malformed
  • No deserializer found for type T

Implementation

@override
T readXmlValue<T>(String xml, Class<T> type) {
  final parser = getXmlParser(xml);
  final result = getXmlDeserializationContext().deserialize(parser, type);
  parser.close();
  return result;
}