Difference between revisions of "XElement class"
(Created page with "=== XElement : An element in an xml document === ==== Constructors ==== (Params AnyType) - Create a new element with a number of child elements<br>(string xml (A xml str...") |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | === XElement | + | {{CGscriptClass_Template |
+ | |Name=<nowiki>XElement</nowiki> | ||
+ | |Description=<nowiki>An element in an xml document</nowiki> | ||
+ | |InheritsFrom=object|Constructors= | ||
+ | {{CGscriptConstructors_Template|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} | ||
+ | |Description=<nowiki>Create a new element with a number of child elements</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>xml</nowiki>|Description=<nowiki>A xml string</nowiki>}} | ||
+ | |Description=<nowiki>Create a new element from a string</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of the element</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value of the element</nowiki>}} | ||
+ | |Description=<nowiki>Create a new element with a name and value</nowiki>}} | ||
+ | |Methods= | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Add</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to add</nowiki>}} | ||
+ | |Description=<nowiki>Adds the specified content as children of this element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Add</nowiki>|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} | ||
+ | |Description=<nowiki>Adds the specified content as children of this element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddAfterSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to add</nowiki>}} | ||
+ | |Description=<nowiki>Adds the specified content immediately after this node.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddBeforeSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to add</nowiki>}} | ||
+ | |Description=<nowiki>Adds the specified content immediately before this node.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddFirst</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to add</nowiki>}} | ||
+ | |Description=<nowiki>Adds the specified content as the first children of this document or element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddFirst</nowiki>|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} | ||
+ | |Description=<nowiki>Adds the specified content as the first children of this document or element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Ancestors</nowiki>|Description=<nowiki>Returns a collection of the ancestor elements of this node.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Ancestors</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a filtered collection of the ancestor elements of this node. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>AncestorsAndSelf</nowiki>|Description=<nowiki>Returns a collection of elements that contain this element, and the ancestors of this element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>AncestorsAndSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a collection of elements that contain this element, and the ancestors of this element. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Descendants</nowiki>|Description=<nowiki>Returns a collection of the descendant elements for this document or element, in document order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Descendants</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a collection of the descendant elements for this document or element, in document order. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>DescendantsAndSelf</nowiki>|Description=<nowiki>Returns a collection of elements that contain this element, and all descendant elements of this element, in document order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>DescendantsAndSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a filtered collection of elements that contain this element, and all descendant elements of this element, in document order. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=XElement|Name=<nowiki>Element</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Gets the first (in document order) child element with the specified name.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Elements</nowiki>|Description=<nowiki>Returns a collection of the child elements of this element or document, in document order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>Elements</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a collection of the child elements of this element or document, in document order. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>ElementsAfterSelf</nowiki>|Description=<nowiki>Returns a collection of the sibling elements after this node, in document order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>ElementsAfterSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a filtered collection of the sibling elements after this node, in document order. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>ElementsBeforeSelf</nowiki>|Description=<nowiki>Returns a collection of the sibling elements before this node, in document order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of XElement|Name=<nowiki>ElementsBeforeSelf</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Returns a filtered collection of the sibling elements before this node, in document order. Only elements that have a matching name are included in the collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>attributename</nowiki>|Description=<nowiki>The attribute name.</nowiki>}} | ||
+ | |Description=<nowiki>Gets an attribute value.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>HasElement</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Name of ancestor to look for</nowiki>}} | ||
+ | |Description=<nowiki>Check if a child element exists with the specified name.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Remove</nowiki>|Description=<nowiki>Removes this node from its parent.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveAll</nowiki>|Description=<nowiki>Removes nodes and attributes from this element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveAttributes</nowiki>|Description=<nowiki>Removes attributes from this element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveNodes</nowiki>|Description=<nowiki>Removes the child nodes from this document or element.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>ReplaceWith</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to replace with</nowiki>}} | ||
+ | |Description=<nowiki>Replaces this node with the specified content.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>ReplaceWith</nowiki>|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} | ||
+ | |Description=<nowiki>Replaces this node with the specified content.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>ReplaceWith</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>content</nowiki>|Description=<nowiki>Content to replace with</nowiki>}} | ||
+ | |Description=<nowiki>Replaces the children nodes of this document or element with the specified content.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>ReplaceWith</nowiki>|Parameters={{CGscriptParameters_Template|Type=params AnyType|Name=params AnyType|Description=}} | ||
+ | |Description=<nowiki>Replaces the children nodes of this document or element with the specified content.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>this[] { set; }</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=string|Name=<nowiki>attributename</nowiki>|Description=<nowiki>The attribute name.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set.</nowiki>}} | ||
+ | |Description=<nowiki>Sets an attribute value.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}} | ||
+ | |Properties= | ||
+ | {{CGscriptProperties_Template|ReturnType=Dictionary|Name=<nowiki>Attributes</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/sets the collection of attributes of this element. The get returns a copy, use the indexer instead.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>HasAttributes</nowiki>|HasGetter=1|Description=<nowiki>Gets a value indicating whether this element as at least one attribute.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>HasElements</nowiki>|HasGetter=1|Description=<nowiki>Gets a value indicating whether this element has at least one child element.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>IsEmpty</nowiki>|HasGetter=1|Description=<nowiki>Gets a value indicating whether this element contains no content.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Gets/sets the name of this element.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=XElement|Name=<nowiki>Parent</nowiki>|HasGetter=1|Description=<nowiki>Gets the parent XElement</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Value</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Gets/sets the concatenated text contents of this element.</nowiki>}} | ||
+ | }} | ||
− | ==== | + | ==== <span style="color:#a52a2a;">Examples</span> ==== |
− | |||
− | |||
− | |||
− | = | ||
− | |||
− | |||
− | ==== | ||
− | |||
− | |||
− |
Latest revision as of 05:46, 2 July 2020
XElement
An element in an xml document
Parent class
Inherits from object
Constructors
- (params AnyType) - Create a new element with a number of child elements
- (string xml "A xml string") - Create a new element from a string
- (string name "Name of the element", object value "Value of the element") - Create a new element with a name and value
Methods
- Empty Add(object content "Content to add") - Adds the specified content as children of this element.
- Empty Add(params AnyType) - Adds the specified content as children of this element.
- Empty AddAfterSelf(object content "Content to add") - Adds the specified content immediately after this node.
- Empty AddBeforeSelf(object content "Content to add") - Adds the specified content immediately before this node.
- Empty AddFirst(object content "Content to add") - Adds the specified content as the first children of this document or element.
- Empty AddFirst(params AnyType) - Adds the specified content as the first children of this document or element.
- Array of XElement Ancestors() - Returns a collection of the ancestor elements of this node.
- Array of XElement Ancestors(string name "Name of ancestor to look for") - Returns a filtered collection of the ancestor elements of this node. Only elements that have a matching name are included in the collection.
- Array of XElement AncestorsAndSelf() - Returns a collection of elements that contain this element, and the ancestors of this element.
- Array of XElement AncestorsAndSelf(string name "Name of ancestor to look for") - Returns a collection of elements that contain this element, and the ancestors of this element. Only elements that have a matching name are included in the collection.
- Array of XElement Descendants() - Returns a collection of the descendant elements for this document or element, in document order.
- Array of XElement Descendants(string name "Name of ancestor to look for") - Returns a collection of the descendant elements for this document or element, in document order. Only elements that have a matching name are included in the collection.
- Array of XElement DescendantsAndSelf() - Returns a collection of elements that contain this element, and all descendant elements of this element, in document order.
- Array of XElement DescendantsAndSelf(string name "Name of ancestor to look for") - Returns a filtered collection of elements that contain this element, and all descendant elements of this element, in document order. Only elements that have a matching name are included in the collection.
- XElement Element(string name "Name of ancestor to look for") - Gets the first (in document order) child element with the specified name.
- Array of XElement Elements() - Returns a collection of the child elements of this element or document, in document order.
- Array of XElement Elements(string name "Name of ancestor to look for") - Returns a collection of the child elements of this element or document, in document order. Only elements that have a matching name are included in the collection.
- Array of XElement ElementsAfterSelf() - Returns a collection of the sibling elements after this node, in document order.
- Array of XElement ElementsAfterSelf(string name "Name of ancestor to look for") - Returns a filtered collection of the sibling elements after this node, in document order. Only elements that have a matching name are included in the collection.
- Array of XElement ElementsBeforeSelf() - Returns a collection of the sibling elements before this node, in document order.
- Array of XElement ElementsBeforeSelf(string name "Name of ancestor to look for") - Returns a filtered collection of the sibling elements before this node, in document order. Only elements that have a matching name are included in the collection.
- object this[] { get; }(string attributename "The attribute name.") - Gets an attribute value.
- bool HasElement(string name "Name of ancestor to look for") - Check if a child element exists with the specified name.
- Empty Remove() - Removes this node from its parent.
- Empty RemoveAll() - Removes nodes and attributes from this element.
- Empty RemoveAttributes() - Removes attributes from this element.
- Empty RemoveNodes() - Removes the child nodes from this document or element.
- Empty ReplaceWith(object content "Content to replace with") - Replaces this node with the specified content.
- Empty ReplaceWith(params AnyType) - Replaces this node with the specified content.
- Empty ReplaceWith(object content "Content to replace with") - Replaces the children nodes of this document or element with the specified content.
- Empty ReplaceWith(params AnyType) - Replaces the children nodes of this document or element with the specified content.
- Empty this[] { set; }(string attributename "The attribute name.", object value "Value to set.") - Sets an attribute value.
- string ToString() - The string representation of the object.
Properties
- Dictionary Attributes { get; set; } - Get/sets the collection of attributes of this element. The get returns a copy, use the indexer instead.
- bool HasAttributes { get; } - Gets a value indicating whether this element as at least one attribute.
- bool HasElements { get; } - Gets a value indicating whether this element has at least one child element.
- bool IsEmpty { get; } - Gets a value indicating whether this element contains no content.
- string Name { get; set; } - Gets/sets the name of this element.
- string ObjectTypeName { get; } - The name of the type of object.
- XElement Parent { get; } - Gets the parent XElement
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
- string Value { get; set; } - Gets/sets the concatenated text contents of this element.