Class XmlItem
Represents a xml node.
Inheritance
Namespace: FastReport.Utils
Assembly: FastReport.dll
Syntax
public class XmlItem : IDisposable
Constructors
XmlItem()
Initializes a new instance of the XmlItem class with default settings.
Declaration
public XmlItem()
Properties
Count
Gets a number of children in this node.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Item[Int32]
Gets a child node with specified index.
Declaration
public XmlItem this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Index of node. |
Property Value
| Type | Description |
|---|---|
| XmlItem | The node with specified index. |
Items
Gets a list of children in this node.
Declaration
public List<XmlItem> Items { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<XmlItem> |
Name
Gets or sets the node name.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
This property will return "Node" for a node like <Node Text="" Left="0"/>
Parent
Gets or sets the parent for this node.
Declaration
public XmlItem Parent { get; set; }
Property Value
| Type | Description |
|---|---|
| XmlItem |
Properties
Gets or sets a list of properties in this node.
Declaration
public XmlProperty[] Properties { get; set; }
Property Value
| Type | Description |
|---|---|
| XmlProperty[] |
Root
Gets the root node which owns this node.
Declaration
public XmlItem Root { get; }
Property Value
| Type | Description |
|---|---|
| XmlItem |
Value
Gets or sets the node value.
Declaration
public string Value { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
This property will return "ABC" for a node like <Node>ABC</Node>
Methods
Add()
Adds a new child node to this node.
Declaration
public XmlItem Add()
Returns
| Type | Description |
|---|---|
| XmlItem | The new child node. |
AddItem(XmlItem)
Adds a specified node to this node.
Declaration
public void AddItem(XmlItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlItem | item | The node to add. |
Clear()
Clears the child nodes of this node.
Declaration
public void Clear()
ClearProps()
Removes all properties.
Declaration
public void ClearProps()
Dispose()
Disposes the node and all its children.
Declaration
public void Dispose()
Find(String)
Finds the node with specified name.
Declaration
public int Find(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of node to find. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The node with specified name, if found; null otherwise. |
FindItem(String)
Finds the node with specified name.
Declaration
public XmlItem FindItem(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | The name of node to find. |
Returns
| Type | Description |
|---|---|
| XmlItem | The node with specified name, if found; the new node otherwise. |
Remarks
This method adds the node with specified name to the child nodes if it cannot find the node. Do not dispose items, which has been created by this method
GetProp(String)
Gets a property with specified name.
Declaration
public string GetProp(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The property name. |
Returns
| Type | Description |
|---|---|
| System.String | The value of property, if found; empty string otherwise. |
Remarks
This property will return "0" when you request the "Left" property for a node
like <Node Text="" Left="0"/>
IndexOf(XmlItem)
Gets the index of specified node in the child nodes list.
Declaration
public int IndexOf(XmlItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| XmlItem | item | The node to find. |
Returns
| Type | Description |
|---|---|
| System.Int32 | Zero-based index of node, if found; -1 otherwise. |
InsertItem(Int32, XmlItem)
Inserts a specified node to this node.
Declaration
public void InsertItem(int index, XmlItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | index | Position to insert. |
| XmlItem | item | Node to insert. |
RemoveProp(String)
Removes a property with specified name.
Declaration
public bool RemoveProp(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The property name. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if property is removed, false otherwise. |
SetProp(String, String)
Sets the value for a specified property.
Declaration
public void SetProp(string key, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The property name. |
| System.String | value | Value to set. |
Remarks
For example, you have a node like <Node Text="" Left="0"/>. When you set the
"Text" property to "test", the node will be <Node Text="test" Left="0"/>.
If property with specified name is not exist, it will be added.