getXmlComponent method

String getXmlComponent(
  1. String xmlString,
  2. String field
)

Implementation

String getXmlComponent(String xmlString, String field) {
  final startTag = '<$field>';
  final endTag = '</$field>';
  final startIndex = xmlString.indexOf(startTag) + startTag.length;
  final endIndex = xmlString.indexOf(endTag);

  if (startIndex >= 0 && endIndex >= 0 && startIndex < endIndex) {
    return xmlString.substring(startIndex, endIndex);
  }
  return "";
}