Xml class

XML Helpers

Helper functions that can be used by importing xml.dart Example adding an attribute to an XmlElement ```dart XmlElement myNode = XmlElement(); ... setAttribute(myNode, 'color', 'red');

Constructors

Xml()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

attribute({required XmlElement node, required String tag}) → String?
Given an XmlElement and an attribute tag(name) we will get the attribute value
changeAttributeName(XmlElement node, String tag, String name) → void
Changes an XmlElement attribute value
element({required XmlElement node, required String tag, bool innerXmlAsText = false}) → String?
Returns the value of a child XmlElement element
encodeIllegalCharacters(dynamic s) → String?
firstElement({required XmlNode node}) → XmlElement?
Return the first XmlElement child from an XmlNode
fromMap({Map? map, String rootName = 'ROOT'}) → XmlDocument
Returns a single depth XmlDocument from a flat map
get({XmlElement? node, String? tag, bool innerXmlAsText = false}) → String?
Gets the value of a attribute else a child element
getChildElement({required XmlElement node, required String tag}) → XmlElement?
Given a tag(name) returns the first child element of a XmlElement that matches
getChildElements({required XmlElement node, required String tag}) → List<XmlElement>?
Given a tag(name) returns all child elements of a XmlElement that match
getElement({required XmlElement node, required String tag}) → XmlElement?
Returns the nearest XmlElement matching the tag(name) from a parent XmlElement
getRoot(XmlNode parent) → XmlElement?
getRootElement(XmlNode parent) → String
getText(XmlNode? node, {bool innerXmlAsText = false}) → String?
Given an XmlNode this will return the raw XmlNodeType.TEXT String
has({required XmlElement node, required String tag}) → bool
Gets the value of a attribute else a child element
hasAttribute({required XmlElement node, required String tag}) → bool
Given an XmlElement and an attribute tag(name) we will return true if exists
hasChildElements(XmlElement node) → bool
Returns true if there is 1 or more child XmlElements
hasElement({required XmlElement node, required String tag}) → bool
Returns the value of a child XmlElement element
hasIllegalCharacters(String? s) → bool
Check if a String contains characters not allowed in Xml
removeAttribute(XmlElement? node, String tag) → XmlElement?
Changes an XmlElement attribute value
replaceIllegalCharacters(String s, String v) → String
Replaces invalid characters with a String
setAttribute(XmlElement node, String tag, String? value) → void
Changes an XmlElement attribute value
toAttribute(String name, String value) → String
Returns a valid attribute structure key="value" from 2 strings
toElement(String name, String value) → String
Returns a Xml Safe String for a node and its value
toElementMap({required XmlElement node}) → Map<String, dynamic>
Takes an XmlElement and creates a map from the attributes and any children elements
toElementValue(String value) → String
Returns a Xml Safe String for a node value.
toMap({required XmlElement node}) → Map
Takes an XmlElement and creates a map from the attributes and any children elements
toMapList({XmlDocument? document, String? root}) → List<Map>?
Returns a map of every XmlElement from a XmlDocument given a String root
tryParse(String? xml, {bool silent = false}) → XmlDocument?
Takes in a String of valid XML and returns it as a XmlDocument containing all the xml package objects
tryParseException(String? xml) → dynamic