TagXml class
Represents an XML tag that can behave like a POCO class and implement validations and computations
Just extend this class and point your gettes and setters to the XML nodes using getValueFromNode
and setValueForNode
- Inheritance
-
- Object
- XmlNode
- XmlElement
- TagXml
- Implemented types
- Implementers
- Available extensions
- CompareAndSwap
- ValidatorClassExtensions
- XmlAncestorsExtension
- XmlComparisonExtension
- XmlDescendantsExtension
- XmlFindExtension
- XmlFollowingExtension
- XmlMutatorExtension
- XmlNodesExtension
- XmlNormalizerExtension
- XmlParentExtension
- XmlPrecedingExtension
- XmlSiblingExtension
- XmlStringExtension
- XPathExtension
- XPathGenerator
Constructors
- TagXml.fromTagName(String name)
-
Constructs a TagXml instance with the given
name
.
Properties
-
ancestorElements
→ Iterable<
XmlElement> -
Available on XmlNode, provided by the XmlAncestorsExtension extension
Return a lazy Iterable of the ancestor XmlElement nodes of this node (parent, grandparent, ...) in reverse document order.no setter -
ancestors
→ Iterable<
XmlNode> -
Available on XmlNode, provided by the XmlAncestorsExtension extension
Return a lazy Iterable of the ancestors of this node (parent, grandparent, ...) in reverse document order.no setter -
attributes
→ XmlNodeList<
XmlAttribute> -
Return the attribute nodes of this node in document order.
finalinherited
-
childElements
→ Iterable<
XmlElement> -
Return an Iterable over the
XmlElement
children of this node.no setterinherited -
children
→ XmlNodeList<
XmlNode> -
Return the direct children of this node in document order.
finalinherited
- deepArrow → string
-
Return a string with a arrow with length equal to deepLevel
no setter
- deepLevel → int
-
Returns the deep level of the current node.
no setter
- depth → int
-
Available on XmlNode, provided by the XmlParentExtension extension
Return the depth of this node in its tree, a root node has depth 0.no setter -
descendantElements
→ Iterable<
XmlElement> -
Available on XmlNode, provided by the XmlDescendantsExtension extension
Return a lazy Iterable of the descendants XmlElement nodes of this node (attributes, children, grandchildren, ...) in document order.no setter -
descendants
→ Iterable<
XmlNode> -
Available on XmlNode, provided by the XmlDescendantsExtension extension
Return a lazy Iterable of the descendants of this node (attributes, children, grandchildren, ...) in document order.no setter - document → XmlDocument?
-
Available on XmlNode, provided by the XmlParentExtension extension
Return the document that contains this node, ornull
if the node is not part of a document.no setter - firstChild → XmlNode?
-
Return the first child of this node, or
null
if there are no children.no setterinherited - firstElementChild → XmlElement?
-
Return the first child XmlElement, or
null
if there are none.no setterinherited -
following
→ Iterable<
XmlNode> -
Available on XmlNode, provided by the XmlFollowingExtension extension
Return a lazy Iterable of the nodes following this node in document order.no setter -
followingElements
→ Iterable<
XmlElement> -
Available on XmlNode, provided by the XmlFollowingExtension extension
Return a lazy Iterable of the XmlElement nodes following this node in document order.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- hasParent → bool
-
Test whether the node has a parent or not.
no setterinherited
- innerText ↔ String
-
Available on XmlNode, provided by the XmlStringExtension extension
Return the concatenated text value its descendants.getter/setter pair - innerXml ↔ String
-
Available on XmlNode, provided by the XmlStringExtension extension
Return the markup representing the child nodes of this node.getter/setter pair - isSelfClosing ↔ bool
-
Defines whether the element should be self-closing when empty.
getter/setter pairinherited
- lastChild → XmlNode?
-
Return the last child of this node, or
null
if there are no children.no setterinherited - lastElementChild → XmlElement?
-
Return the last child XmlElement, or
null
if there are none.no setterinherited - localName → String
-
Return the local name, excluding the namespace prefix.
no setterinherited
- name → XmlName
-
Return the name of the node.
finalinherited
- namespacePrefix → String?
-
Return the namespace prefix, or
null
.no setterinherited - namespaceUri → String?
-
Return the namespace URI, or
null
.no setterinherited - nextElementSibling → XmlElement?
-
Available on XmlNode, provided by the XmlSiblingExtension extension
Return the next element sibling of this node, ornull
.no setter - nextSibling → XmlNode?
-
Available on XmlNode, provided by the XmlSiblingExtension extension
Return the next sibling of this node, ornull
.no setter -
nodes
→ Iterable<
XmlNode> -
Available on XmlNode, provided by the XmlNodesExtension extension
Return a lazy Iterable of the direct descendants of this XmlNode (attributes, children) in document order.no setter - nodeType → XmlNodeType
-
Return the node type of this node.
no setterinherited
- outerXml ↔ String
-
Available on XmlNode, provided by the XmlStringExtension extension
Return the markup representing this node and all its child nodes.getter/setter pair - parent → XmlNode?
-
Return the parent node of this node, or
null
if there is none.no setterinherited - parentElement → XmlElement?
-
Available on XmlNode, provided by the XmlParentExtension extension
Return the first parent of this node that is of type XmlElement, ornull
if there is none.no setter - path → string
-
Returns the path of the current node.
no setter
-
preceding
→ Iterable<
XmlNode> -
Available on XmlNode, provided by the XmlPrecedingExtension extension
Return a lazy Iterable of the nodes preceding this node in document order.no setter -
precedingElements
→ Iterable<
XmlElement> -
Available on XmlNode, provided by the XmlPrecedingExtension extension
Return a lazy Iterable of the XmlElement nodes preceding this node in document order.no setter - previousElementSibling → XmlElement?
-
Available on XmlNode, provided by the XmlSiblingExtension extension
Return the previous element sibling of this node, ornull
.no setter - previousSibling → XmlNode?
-
Available on XmlNode, provided by the XmlSiblingExtension extension
Return the previous sibling of this node, ornull
.no setter - qualifiedName → String
-
Return the fully qualified name, including the namespace prefix.
no setterinherited
- root → XmlNode
-
Available on XmlNode, provided by the XmlParentExtension extension
Return the root of the tree in which this node is found, whether that's a document or another element.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
siblingElements
→ List<
XmlElement> -
Available on XmlNode, provided by the XmlSiblingExtension extension
Returns an Iterable over the XmlElement siblings of this node. If the node has no parent or no siblings, return an empty collection.no setter -
siblings
→ List<
XmlNode> -
Available on XmlNode, provided by the XmlSiblingExtension extension
Returns a List of the siblings of this node. Throws an XmlParentException if the node has no parent.no setter - tagName ↔ string
-
Gets or sets the tag name.
getter/setter pair
- text → String
-
Returns the concatenated text of this node or its descendants, for
text, CDATA, and comment nodes return the textual value of the node.
no setterinherited
- value → String?
-
Returns the value of the node, or
null
.no setterinherited
Methods
-
accept(
XmlVisitor visitor) → void -
Dispatch the invocation depending on this type to the
visitor
.inherited -
attachParent(
covariant XmlNode parent) → void -
Internal helper to attach a child to this parent, do not call directly.
inherited
-
compareAndSwap(
T other) → Iterable< T> -
Available on T, provided by the CompareAndSwap extension
Compares the current value with theother
value and swaps them if necessary. -
compareNodePosition(
XmlNode other) → int -
Available on XmlNode, provided by the XmlComparisonExtension extension
Compares the position of this node andother
. -
compareTo(
dynamic other) → int -
compare this tag with another tag
override
-
compute(
) → void - compute this tag
-
computeAndValidate(
[bool throwException = false]) → bool -
Compute and validate this tag.
If
throwException
istrue
, it throws an InvalidException if the tag is not valid. -
contains(
XmlNode other) → bool -
Available on XmlNode, provided by the XmlComparisonExtension extension
Test whetherother
is this node or contained in this node. -
copy(
) → XmlElement -
Return a copy of this node and all its children.
inherited
-
detachParent(
covariant XmlNode parent) → void -
Internal helper to detach a child from its parent, do not call directly.
inherited
-
findAllElements(
String name, {String? namespace}) → Iterable< XmlElement> -
Available on XmlNode, provided by the XmlFindExtension extension
Return a lazy Iterable of the recursive child elements in document order with the specified tagname
. -
findElements(
String name, {String? namespace}) → Iterable< XmlElement> -
Available on XmlNode, provided by the XmlFindExtension extension
Return a lazy Iterable of the direct child elements in document order with the specified tagname
andnamespace
. -
getAttribute(
String name, {String? namespace}) → String? -
Return the attribute value with the given
name
, ornull
.inherited -
getAttributeNode(
String name, {String? namespace}) → XmlAttribute? -
Return the attribute node with the given
name
, ornull
.inherited -
getElement(
String name, {String? namespace}) → XmlElement? -
Return the first child element with the given
name
, ornull
.inherited -
getFirstChild(
String tagName) → XmlElement? -
Returns a child node with the given
tagName
. -
getTagAs<
T extends TagXml> (String tag, T constructor()) → T? -
Returns a child node with the given
tag
as an instance ofT
. -
getTagsFrom<
T extends TagXml> (String tagName, T itemConstructor()) → Iterable< T> -
Returns an iterable of child nodes with the given
tagName
as instances ofT
. -
getTagsFromNodeList<
T extends TagXml> (String listName, string itemName, T constructor()) → Iterable< T> -
getValueFromNode<
T> (String tag, [T parser(string i)?]) → T? -
Returns the text value from a specific child node with the given
tag
. -
hasChildren(
String tagName) → bool -
check if children with
tagName
exists -
isEqualNode(
XmlNode other) → bool -
Available on XmlNode, provided by the XmlComparisonExtension extension
Tests whether this node is equal toother
. -
isIn<
T extends TagXml> (T tag) → bool -
Checks if this node is a descendant of the given
tag
. -
isInDocument<
T extends TagXml> (T tag) → bool -
Checks if this node is a descendant of the document thats
tag
is. -
normalize(
{Predicate< XmlText> ? collapseWhitespace, bool? collapseAllWhitespace, Predicate<XmlText> ? normalizeNewline, bool? normalizeAllNewline, Predicate<XmlText> ? trimWhitespace, bool? trimAllWhitespace}) → void -
Available on XmlNode, provided by the XmlNormalizerExtension extension
Puts all child nodes into a "normalized" form, that is -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pathJoin(
[string joiner = "."]) → string -
Returns the path of the current node.
The
joiner
is used to join the path segments. -
remove(
) → void -
Available on XmlNode, provided by the XmlMutatorExtension extension
Remove this node from parent. -
removeAttribute(
String name, {String? namespace}) → void -
Removes the attribute value with the given fully qualified
name
.inherited -
removeChildren(
string tagName) → void -
Remove all child nodes with the given
tagName
. -
renameChildren(
string oldTagName, string newTagName) → void -
replace(
XmlNode other) → void -
Available on XmlNode, provided by the XmlMutatorExtension extension
Replace this node withother
. -
setAttribute(
String name, String? value, {String? namespace}) → void -
Set the attribute value with the given fully qualified
name
tovalue
. If an attribute with the name already exist, its value is updated. If the value isnull
, the attribute is removed.inherited -
setNodeList<
T extends TagXml, V extends TagXml> (String listRootTag, Iterable< V> values) → void - Add a node thats wrap a list of child nodes
-
setTagFrom<
T extends TagXml> (String childName, T? value) → T? -
Sets a child node with the given
childName
to the providedvalue
. -
setValueForNode<
T, V> (String tag, V? value) → void -
Sets the text value for a specific child node with the given
tag
. -
toString(
) → String -
Compute and return the preety XML string representation of the node.
override
-
toXmlString(
{bool pretty = false, XmlEntityMapping? entityMapping, int? level, String? indent, String? newLine, Predicate< XmlNode> ? preserveWhitespace, Predicate<XmlAttribute> ? indentAttribute, Comparator<XmlAttribute> ? sortAttributes, Predicate<XmlNode> ? spaceBeforeSelfClose}) → String -
Return an XML string of this object.
inherited
-
validate(
) → Iterable< String> -
Validates the current instance and returns a list of error messages if the instance is invalid.
override
-
validateOrThrow<
T extends Exception> ([T exception(Iterable< String> errors)?]) → void -
Available on Validator, provided by the ValidatorClassExtensions extension
Validates the object and throws an exception if there are any errors. -
xpath(
String expression, {Map< String, XPathValue> variables = const {}, Map<String, XPathFunction> functions = const {}}) → Iterable<XmlNode> -
Available on XmlNode, provided by the XPathExtension extension
Returns an iterable over the nodes matching the provided XPathexpression
. -
xpathEvaluate(
String expression, {Map< String, XPathValue> variables = const {}, Map<String, XPathFunction> functions = const {}}) → XPathValue -
Available on XmlNode, provided by the XPathExtension extension
Returns the value resulting from evaluating the given XPathexpression
. -
xpathGenerate(
{String? byId}) → String -
Available on XmlNode, provided by the XPathGenerator extension
Returns an XPath string that can be used to query for this XmlNode.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromXmlString<
T extends TagXml> (string xml, T constructor()) → T? -
Create a instance of
T
from a XML string and using the providedconstructor
. Theconstructor
is a function that creates a new instance ofT
and returns it. -
fromXmlStringList<
T extends TagXml> (string xml, T constructor()) → Iterable< T> -
Create a list of instances of
T
from a XML string and using the providedconstructor
. Theconstructor
is a function that creates a new instance ofT
and returns it. Provide the tagName ifT
name is different fom tagName. -
mutate<
T extends TagXml> (XmlNode? element, T constructor(), [bool force = false]) → T? -
Mutate a XmlElement into a TagXml of type
T
.