XmlElement class
A XML element.
For the purposes of this package, an element can either be an XML element (a tag) or a nested plain text value, in which case only the text value is supplied.
- Inheritance
-
- Object
- XmlNode
- XmlNodeWithChildren
- XmlElement
- Annotations
-
- @immutable
Constructors
-
XmlElement({required String name, List<
XmlAttribute> ? attributes, List<XmlNode> ? children}) -
A XML element.
const
Properties
-
attributes
→ List<
XmlAttribute> ? -
This element's declared attributes.
final
-
children
→ List<
XmlNode> ? -
The list of children each getter and method references.
finalinherited
- firstChild → XmlElement?
-
Returns the first XmlElement found in children.
no setterinherited
- hasChildren → bool
-
Returns
true
if children isn't null or empty.no setterinherited - hashCode → int
-
The hash code for this object.
no setteroverride
- id → String?
-
The
id
attribute of this element.no setter - lastChild → XmlElement?
-
Returns the last XmlElement found in children.
no setterinherited
- name → String
-
The name of this element.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- text → String?
-
Returns all of the top-level text nodes found in children
and returns them combined into a string.
no setter
Methods
-
compareTo(
XmlNode element, {bool matchAllAttributes = false, bool attributesMustBeIdentical = false, bool childrenMustBeIdentical = false}) → bool -
Compares this element to
element
and returnstrue
if this element posesses all ofelement
's values, otherwise returnsfalse
. -
copyWith(
{String? name, List< XmlAttribute> ? attributes, List<XmlNode> ? children, bool copyNull = false}) → XmlElement - Copies this element with the provided values.
-
getAttribute(
String attributeName) → String? -
Returns the value of the first attribute named
attributeName
if it exists, otherwise returnsnull
. -
getChild(
String elementName) → XmlElement? -
Returns the first direct child named
elementName
.inherited -
getChildren(
String elementName, {int start = 0, int? stop}) → List< XmlElement> ? -
Returns all direct children named
elementName
.inherited -
getChildrenWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false, int start = 0, int? stop}) → List<XmlElement> ? -
Returns all direct children with properties matching those specified.
inherited
-
getChildWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Returns all direct children with properties matching those specified.
inherited
-
getElement(
String elementName) → XmlElement? -
Recursively checks all elements within this node tree and
returns the first element found named
elementName
.inherited -
getElements(
String elementName, {bool ignoreNestedMatches = true, int start = 0, int? stop}) → List< XmlElement> ? -
Recursively checks all elements within this node tree and
returns any elements found named
elementName
.inherited -
getElementsWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false, bool ignoreNestedMatches = true, int start = 0, int? stop, bool global = true, bool reversed = false}) → List<XmlElement> ? -
Recursively checks all elements within the node tree and returns
any elements found with properties matching those specified.
inherited
-
getElementWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Recursively checks all elements within the node tree and returns
the first element found with properties matching those specified.
inherited
-
getLastChild(
String elementName) → XmlElement? -
Returns the last direct child named
elementName
.inherited -
getLastChildWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Returns the last direct child with properties matching those specified.
inherited
-
getLastElement(
String elementName) → XmlElement? -
Recursively checks all elements within this node tree and
returns the last element found named
elementName
.inherited -
getLastElementWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Recursively checks all elements within the node tree and returns
the last element found with properties matching those specified.
inherited
-
getNthChild(
int index, String elementName) → XmlElement? -
Returns the nth direct child named
elementName
.inherited -
getNthChildWhere(
int index, {String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Returns the nth direct child with properties matching those specified.
inherited
-
getNthElement(
int index, String elementName, {bool ignoreNestedMatches = true}) → XmlElement? -
Recursively checks all elements within this node tree and
returns the nth element found named
elementName
.inherited -
getNthElementWhere(
int index, {String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → XmlElement? -
Recursively checks all elements within the node tree and returns
the nth element found with properties matching those specified.
inherited
-
hasAttribute(
String attributeName) → bool -
Returns true if this element has an attribute named
attributeName
. -
hasAttributeWhere(
String attributeName, String attributeValue) → bool -
Returns true if this element has an attribute named
attributeName
and a value ofattributeValue
. -
hasChild(
String elementName) → bool -
Returns
true
if this element contains a direct child namedelementName
.inherited -
hasChildWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false}) → bool -
Returns
true
ifchildren
contains a direct child with properties matching those specified.inherited -
hasElement(
String elementName) → bool -
Recursively checks all nested elements and returns
true
if one is found namedelementName
.inherited -
hasElementWhere(
{String? name, String? id, List< String> ? attributeNames, List<XmlAttribute> ? attributes, bool matchAllAttributes = false, bool attributesMustBeIdentical = false, List<XmlNode> ? children, bool matchAllChildren = false, bool childrenMustBeIdentical = false, bool global = false}) → bool -
Recursively checks all nested elements and returns
true
if one is found with properties matching those specified.inherited -
loadExternalDtd(
) → Future< void> - Attempts to load all external DTD references contained within any nested XmlDoctypes and XmlEntitys, load the pages they reference, and parse the DTD elements contained within.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nthChild(
int index) → XmlElement? -
Returns the nth XmlElement found in children.
inherited
-
toFormattedString(
{int nestingLevel = 0, String indent = '\t', bool encodeCharacterEntities = true, String? encodeCharacters, bool doubleQuotes = true}) → String -
Returns this node as a formatted string.
override
-
toString(
{bool doubleQuotes = true, bool encodeCharacterEntities = true, String? encodeCharacters}) → String -
Returns this element as an unformatted XML string.
override
Operators
-
operator ==(
Object o) → bool -
The equality operator.
override
Static Methods
-
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}) → XmlElement? -
Returns the first element found in
string
.string
must not benull
.override -
parseString(
String string, {bool parseCharacterEntities = true, bool parseComments = false, bool trimWhitespace = true, bool parseCdataAsText = true, bool global = false, List< String> ? returnElementsNamed, List<String> ? returnElementsWithId, List<String> ? returnElementsWithAttributesNamed, List<XmlAttribute> ? returnElementsWithAttributes, bool matchAllAttributes = true, int start = 0, int? stop}) → List<XmlElement> ? -
Returns a list of every element found in
string
.string
must not benull
.override