validateXml static method

bool validateXml(
  1. String xmlStr
)

Returns true if xmlStr is well-formed XML, false otherwise.

Uses the xml package for strict parsing.

Implementation

static bool validateXml(String xmlStr) {
  if (xmlStr.trim().isEmpty) return false;
  try {
    xml.XmlDocument.parse(xmlStr);
    return true;
  } catch (_) {
    return false;
  }
}