xmlFromResponse function

Future<XmlElement> xmlFromResponse(
  1. StreamedResponse rs, {
  2. String? resultWrapper,
})

Implementation

Future<XmlElement> xmlFromResponse(StreamedResponse rs,
    {String? resultWrapper}) async {
  final body = await rs.stream.bytesToString();
  if (body.isNotEmpty) {
    var elem = XmlDocument.parse(body).rootElement;

    if (resultWrapper != null) {
      elem = elem.findElements(resultWrapper).first;
    }
    return elem;
  } else {
    return XmlElement(XmlName('empty'));
  }
}