OcDeviceParameter.fromXML constructor

OcDeviceParameter.fromXML(
  1. String xmlSTR
)

Implementation

factory OcDeviceParameter.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("ocStatus");

  VendorModelInfo vendorModelInfo =
      VendorModelInfo.fromXML(vendorModelInfoElement!.toXmlString());
  IpAndPort ipAndPort = IpAndPort.fromXML(ipAndPortElement!.toXmlString());
  OcStatus status = OcStatus.fromXML(statusElement!.toXmlString());

  String numCharsPerLine = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "numCharsPerLine")
      .value;
  String numLines = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "numLines")
      .value;
  String style = document.firstChild!.attributes
      .firstWhere((element) => element.name.toString() == "style")
      .value;
  return OcDeviceParameter(
      vendorModelInfo: vendorModelInfo,
      ipAndPort: ipAndPort,
      status: status,
      numCharsPerLine: numCharsPerLine,
      numLines: numLines,
      style: style);
}