C# Class GSF.Xml.XmlExtensions

Defines extension functions related to Xml elements.
Exibir arquivo Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
ApplyXSLTransform ( this document, string transform ) : string

Transforms an XML document using the given XSL template.

Format ( this element ) : object

Formats the contents of an XML element and returns the result.

The format to be used is determined by the type and spec attributes of the element. The type attribute should be the fully qualified type name of an IFormattable type. The spec attribute defines the format string to be used when formatting the contents. If type or spec are not defined or if type resovles to a type that is not IFormattable, the contents are not formatted and are returned as-is.

GetAttributeValue ( this node, string name ) : string

Safely gets or sets an XML node's attribute.

If you get an attribute that does not exist, null will be returned.

GetDataSet ( this xmlData ) : DataSet

Gets a data set object from an XML data set formatted as a String.

GetXmlNode ( this xmlDoc, string xpath ) : XmlNode

Gets an XML node from given path, creating the entire path if it does not exist.

This overload just allows the start of the given XML document by using its root element.

GetXmlNode ( this xmlDoc, string xpath, bool &isDirty ) : XmlNode

Gets an XML node from given path, creating the entire path if it does not exist.

This overload just allows the start of the given XML document by using its root element.

Note that the isDirty parameter will be set to True if any items were added to the tree.

SetAttributeValue ( this node, string name, string value ) : void

Safely sets an XML node's attribute.

If you assign a value to an attribute that does not exist, the attribute will be created.

Private Methods

Method Description
TransformAll ( this document, System.Xml.Linq.XName name, Func selector ) : void
TransformAll ( this document, System.Xml.Linq.XName name, object>.Func selector ) : void

Method Details

ApplyXSLTransform() public static method

Transforms an XML document using the given XSL template.
public static ApplyXSLTransform ( this document, string transform ) : string
document this The document to be transformed.
transform string The template that defines how the data should be transformed.
return string

Format() public static method

Formats the contents of an XML element and returns the result.
The format to be used is determined by the type and spec attributes of the element. The type attribute should be the fully qualified type name of an IFormattable type. The spec attribute defines the format string to be used when formatting the contents. If type or spec are not defined or if type resovles to a type that is not IFormattable, the contents are not formatted and are returned as-is.
public static Format ( this element ) : object
element this The elements whose contents are to be formatted.
return object

GetAttributeValue() public static method

Safely gets or sets an XML node's attribute.
If you get an attribute that does not exist, null will be returned.
public static GetAttributeValue ( this node, string name ) : string
node this A to query.
name string A name of the value to get.
return string

GetDataSet() public static method

Gets a data set object from an XML data set formatted as a String.
public static GetDataSet ( this xmlData ) : DataSet
xmlData this XML data string in standard DataSet format.
return System.Data.DataSet

GetXmlNode() public static method

Gets an XML node from given path, creating the entire path if it does not exist.
This overload just allows the start of the given XML document by using its root element.
public static GetXmlNode ( this xmlDoc, string xpath ) : XmlNode
xmlDoc this An to query.
xpath string A xpath query.
return System.Xml.XmlNode

GetXmlNode() public static method

Gets an XML node from given path, creating the entire path if it does not exist.

This overload just allows the start of the given XML document by using its root element.

Note that the isDirty parameter will be set to True if any items were added to the tree.

public static GetXmlNode ( this xmlDoc, string xpath, bool &isDirty ) : XmlNode
xmlDoc this An to query.
xpath string A xpath query.
isDirty bool A value indicating if items were added to the tree.
return System.Xml.XmlNode

SetAttributeValue() public static method

Safely sets an XML node's attribute.
If you assign a value to an attribute that does not exist, the attribute will be created.
public static SetAttributeValue ( this node, string name, string value ) : void
node this An node to operate on.
name string A indicating the node name to use.
value string A value to set the node attribute's value to.
return void