Class ExtensionsXml
Xml Extension methods.
Inherited Members
Namespace: System.Xml.Linq
Assembly: Acoustics.Shared.dll
Syntax
public static class ExtensionsXml
Methods
| Improve this Doc View SourceAbsoluteXPath(XElement)
Get the absolute XPath to a given XElement (e.g. "/people/person[6]/name[1]/last[1]").
Declaration
public static string AbsoluteXPath(this XElement element)
Parameters
Type | Name | Description |
---|---|---|
XElement | element | The element to get the index of. |
Returns
Type | Description |
---|---|
String | The absolute x path. |
Remarks
Extension methods for the .NET 3.5 System.Xml.Linq namespace. From: http://seattlesoftware.wordpress.com/2009/03/13/get-the-xpath-to-an-xml-element-xelement/.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
DeserializeObject<T>(String)
Reconstruct an object from an XML string.
Declaration
public static T DeserializeObject<T>(this string xml)
Parameters
Type | Name | Description |
---|---|---|
String | xml | serialized xml string. |
Returns
Type | Description |
---|---|
T | Deserialised object T. |
Type Parameters
Name | Description |
---|---|
T | Type of object to deserialise. |
IndexPosition(XElement)
Get the index of the given XElement relative to its siblings with identical names. If the given element is the root, -1 is returned.
Declaration
public static int IndexPosition(this XElement element)
Parameters
Type | Name | Description |
---|---|---|
XElement | element | The element to get the index of. |
Returns
Type | Description |
---|---|
Int32 | The index position. |
Remarks
Extension methods for the .NET 3.5 System.Xml.Linq namespace. From: http://seattlesoftware.wordpress.com/2009/03/13/get-the-xpath-to-an-xml-element-xelement/.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException | element has been removed from its parent. |
SerializeObject<T>(T)
Serialize an object into an XML string.
Declaration
public static string SerializeObject<T>(this T obj)
Parameters
Type | Name | Description |
---|---|---|
T | obj | Object to serialise. |
Returns
Type | Description |
---|---|
String | Object serialised as xml string. |
Type Parameters
Name | Description |
---|---|
T | Type of object to serialise. |
ToXDocument(XmlDocument)
Declaration
public static XDocument ToXDocument(this XmlDocument xmlDoc)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | xmlDoc |
Returns
Type | Description |
---|---|
XDocument |
ToXElement(XmlElement)
Declaration
public static XElement ToXElement(this XmlElement xmlEl)
Parameters
Type | Name | Description |
---|---|---|
XmlElement | xmlEl |
Returns
Type | Description |
---|---|
XElement |
ToXmlDocument(XDocument)
Declaration
public static XmlDocument ToXmlDocument(this XDocument xDoc)
Parameters
Type | Name | Description |
---|---|---|
XDocument | xDoc |
Returns
Type | Description |
---|---|
XmlDocument |
ToXmlElement(XElement)
Declaration
public static XmlElement ToXmlElement(this XElement xEl)
Parameters
Type | Name | Description |
---|---|---|
XElement | xEl |
Returns
Type | Description |
---|---|
XmlElement |