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
XmlElementand an attribute tag(name) we will get the attribute value -
changeAttributeName(
XmlElement node, String tag, String name) → void -
Changes an
XmlElementattribute value -
element(
{required XmlElement node, required String tag, bool innerXmlAsText = false}) → String? -
Returns the value of a child
XmlElementelement -
encodeIllegalCharacters(
dynamic s) → String? -
firstElement(
{required XmlNode node}) → XmlElement? -
Return the first
XmlElementchild from anXmlNode -
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
XmlElementthat matches -
getChildElements(
{required XmlElement node, required String tag}) → List< XmlElement> ? -
Given a tag(name) returns all child elements of a
XmlElementthat match -
getElement(
{required XmlElement node, required String tag}) → XmlElement? -
Returns the nearest
XmlElementmatching the tag(name) from a parentXmlElement -
getRoot(
XmlNode parent) → XmlElement? -
getRootElement(
XmlNode parent) → String -
getText(
XmlNode? node, {bool innerXmlAsText = false}) → String? -
Given an
XmlNodethis will return the rawXmlNodeType.TEXTString -
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
XmlElementand 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
XmlElementelement -
hasIllegalCharacters(
String? s) → bool - Check if a String contains characters not allowed in Xml
-
removeAttribute(
XmlElement? node, String tag) → XmlElement? -
Changes an
XmlElementattribute value -
replaceIllegalCharacters(
String s, String v) → String - Replaces invalid characters with a String
-
setAttribute(
XmlElement node, String tag, String? value) → void -
Changes an
XmlElementattribute 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
XmlElementand 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
XmlElementand creates a map from the attributes and any children elements -
toMapList(
{XmlDocument? document, String? root}) → List< Map> ? -
Returns a map of every
XmlElementfrom aXmlDocumentgiven a String root -
tryParse(
String? xml, {bool silent = false}) → XmlDocument? -
Takes in a String of valid XML and returns it as a
XmlDocumentcontaining all the xml package objects -
tryParseException(
String? xml) → dynamic