PrDeviceParameter.fromXML constructor
PrDeviceParameter.fromXML(
- String xmlSTR
Implementation
factory PrDeviceParameter.fromXML(String xmlSTR) {
final document = XmlDocument.parse(xmlSTR);
XmlElement? vendorModelInfoElement = document.firstChild!.getElement("vendorModelInfo");
XmlElement? ipAndPortElement = document.firstChild!.getElement("ipAndPort");
XmlElement? statusElement = document.firstChild!.getElement("prStatus");
VendorModelInfo vendorModelInfo = VendorModelInfo.fromXML(vendorModelInfoElement!.toXmlString());
IpAndPort ipAndPort = IpAndPort.fromXML(ipAndPortElement!.toXmlString());
PrStatus status = PrStatus.fromXML(statusElement!.toXmlString());
XmlElement? supportedStocksElement = document.firstChild!.getElement("supportedStocks");
List<XmlElement> supporters = supportedStocksElement == null ? [] : supportedStocksElement.findElements("supportedStock").toList();
String supportsColor = document.firstChild!.attributes.firstWhere((element) => element.name.toString() == "supportsColor", orElse: orElseEmpty).value;
List<SupportedStock> supportedStocks = supporters.map((e) => SupportedStock.fromXML(e.toXmlString())).toList();
return PrDeviceParameter(vendorModelInfo: vendorModelInfo, ipAndPort: ipAndPort, status: status, supportsColor: supportsColor, supportedStocks: supportedStocks);
}