parse method

DeviceInfo parse(
  1. Uri uri
)

Implementation

DeviceInfo parse(Uri uri) {
  String URLBase = "";
  try {
    URLBase = doc.findAllElements('URLBase').first.text;
  } catch (e) {
    URLBase = uri.origin;
  }
  final deviceType = doc.findAllElements('deviceType').first.text;
  final friendlyName = doc.findAllElements('friendlyName').first.text;
  final serviceList =
      doc.findAllElements('serviceList').first.findAllElements('service');
  final serviceListItems = [];
  for (final service in serviceList) {
    final serviceType = service.findElements('serviceType').first.text;
    final serviceId = service.findElements('serviceId').first.text;
    final controlURL = service.findElements('controlURL').first.text;
    serviceListItems.add({
      "serviceType": serviceType,
      "serviceId": serviceId,
      "controlURL": controlURL,
    });
  }
  return DeviceInfo(URLBase, deviceType, friendlyName, serviceListItems);
}