from static method

XmlElement? from(
  1. String string, {
  2. bool parseCharacterEntities = true,
  3. bool parseComments = false,
  4. bool trimWhitespace = true,
  5. bool parseCdataAsText = true,
  6. List<String>? returnElementsNamed,
  7. List<String>? returnElementsWithId,
  8. List<String>? returnElementsWithAttributesNamed,
  9. List<XmlAttribute>? returnElementsWithAttributes,
  10. bool matchAllAttributes = true,
})
override

Returns the first element found in string. string must not be null.

If parseCharacterEntities is true, text values will be parsed and replace all encoded character entities with their corresponding character. parseCharacterEntities must not be null.

If parseComments is true, commments will be scrubbed from string before parsing.

If trimWhitespace is true, unnecessary whitespace between nodes will be removed and all remaining whitespace will be replaced with a single space. trimWhitespace must not be null.

If parseCdataAsText is true, all CDATA sections will be returned as XmlText nodes. parseCdataAsText must not be null.

If returnElementsNamed is not null, only elements with a name contained in returnElementsNamed will be returned.

If returnElementsWithId is not null, only elements with an ID contained in returnElementsWithId will be returned.

If returnElementsWithAttributesNamed is not null, only elements posessing an attribute with a name contained in returnElementsWithAttributesNamed will be returned. If matchAllAttributes is true, an element must possess every attribute contained in returnElementsWithAttributesNamed to be returned, if false, the element only needs to posess a single attribute contained in returnElementsWithAttributesNamed.

If returnElementsWithAttributes is not null, only elements possessing attributes with an identical name and value as those contained in returnElemtnsWithAttribute will be returned. If matchAllAttributes is true, an element must possess every attribute contained in returnElementsWithAttributes, if false, the element only needs to possess a single attribute contained in returnElementsWithAttributes.

Returns null if no elements were found.

Implementation

static XmlElement? from(
  String string, {
  bool parseCharacterEntities = true,
  bool parseComments = false,
  bool trimWhitespace = true,
  bool parseCdataAsText = true,
  List<String>? returnElementsNamed,
  List<String>? returnElementsWithId,
  List<String>? returnElementsWithAttributesNamed,
  List<XmlAttribute>? returnElementsWithAttributes,
  bool matchAllAttributes = true,
}) {
  return parseString(
    string,
    parseCharacterEntities: parseCharacterEntities,
    parseComments: parseComments,
    trimWhitespace: trimWhitespace,
    parseCdataAsText: parseCdataAsText,
    returnElementsNamed: returnElementsNamed,
    returnElementsWithId: returnElementsWithId,
    returnElementsWithAttributesNamed: returnElementsWithAttributesNamed,
    returnElementsWithAttributes: returnElementsWithAttributes,
    matchAllAttributes: matchAllAttributes,
    stop: 0,
  )?.first;
}