compareTo method

bool compareTo(
  1. XmlNode element, {
  2. bool matchAllAttributes = false,
  3. bool attributesMustBeIdentical = false,
  4. bool childrenMustBeIdentical = false,
})

Compares this element to element and returns true if this element posesses all of element's values, otherwise returns false.

The element's name value is case insensitive.

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.

If attributesMustBeIdentical is true, this elements's attributes must match element's attributes exactly, it may not have any attributes in addition to those possessed by element.

If childrenMustBeIdentical is true, children will be compared with the == operator and must be identical to return true, otherwise they will be compared with this method, compareTo(), in which case this element's children must possess the same values as element's children, but don't need to be identical. If childrenMustBeIdentical is false, this element is allowed to have children in addition to element's.

This element can have values in addition to those of element. Use the == operator if this element and element should be identical.

Implementation

bool compareTo(
  XmlNode element, {
  bool matchAllAttributes = false,
  bool attributesMustBeIdentical = false,
  bool childrenMustBeIdentical = false,
}) {
  if (element is XmlElement) {
    if (XmlNodeWithChildren.compareValues(
      this,
      name: element.name,
      id: element.id,
      attributes: element.attributes,
      matchAllAttributes: matchAllAttributes,
      attributesMustBeIdentical: attributesMustBeIdentical,
      children: element.children,
      matchAllChildren: true,
      childrenMustBeIdentical: childrenMustBeIdentical,
    )) {
      return true;
    }
  }

  return false;
}