Show / Hide Table of Contents

Class ExtXml

Adds extension methods for System.Xml.Linq.XElement and System.Xml.Linq.XDocument.

public static class ExtXml

Namespace: Au.Types
Assembly: Au.dll
Inheritance
object
ExtXml

Methods

Name Description
Attr(XElement, out double, XName)

Gets attribute value converted to double number. If the attribute does not exist, sets value = 0 and returns false. If the attribute value is empty or is not a valid number, sets value = 0 and returns true.

Attr(XElement, out int, XName)

Gets attribute value converted to int number. If the attribute does not exist, sets value = 0 and returns false. If the attribute value is empty or does not begin with a valid number, sets value = 0 and returns true.

Attr(XElement, out long, XName)

Gets attribute value converted to long number. If the attribute does not exist, sets value = 0 and returns false. If the attribute value is empty or does not begin with a valid number, sets value = 0 and returns true.

Attr(XElement, out float, XName)

Gets attribute value converted to float number. If the attribute does not exist, sets value = 0 and returns false. If the attribute value is empty or is not a valid number, sets value = 0 and returns true.

Attr(XElement, out string, XName)

Gets XML attribute value. If the attribute does not exist, sets value = null and returns false.

Attr(XElement, XName)

Gets XML attribute value. If the attribute does not exist, returns null. If the attribute value is empty, returns "".

Attr(XElement, XName, int)

Gets attribute value converted to int number. If the attribute does not exist, returns defaultValue. If the attribute value is empty or does not begin with a valid number, returns 0.

Attr(XElement, XName, string)

Gets XML attribute value. If the attribute does not exist, returns defaultValue. If the attribute value is empty, returns "".

Attr<T>(XElement, out T, XName)

Gets attribute value as enum type T. If the attribute does not exist, sets value = default and returns false. If the attribute value is not a valid enum member name, sets value = default and returns true.

Desc(XElement, XName)

Gets the first found descendant element.

Desc(XElement, XName, XName, string, bool)

Finds the first descendant element that has the specified attribute or value.

Descs(XElement, XName, XName, string, bool)

Finds all descendant elements that have the specified attribute or value.

Elem(XElement, XName, XName, string, bool)

Gets the first found direct child element that has the specified attribute or value.

ElemOrAdd(XElement, XName)

Gets the first found direct child element. If not found, adds new empty child element.

ElemOrAdd(XElement, XName, XName, string, bool)

Gets the first found direct child element that has the specified attribute. If not found, adds new child element with the attribute. More info: ExtXml.Elem

Elems(XElement, XName, XName, string, bool)

Gets all direct child elements that have the specified attribute or value.

HasAttr(XElement, XName)

Returns true if this element has the specified attribute.

NextElem(XElement)

Returns next sibling element or null.

PrevElem(XElement)

Returns previous sibling element or null.

SaveDoc(XDocument, string, bool, SaveOptions?)

Saves XML to a file in a safer way. Uses System.Xml.Linq.XDocument.Save and filesystem.save

SaveElem(XElement, string, bool, SaveOptions?)

Saves XML to a file in a safer way. Uses System.Xml.Linq.XElement.Save and filesystem.save.