mscorlib(4.0.0.0) API with additions
System.Xml.XmlAttribute Class Reference

Represents an attribute. Valid and default values for the attribute are defined in a document type definition (DTD) or schema. More...

Inheritance diagram for System.Xml.XmlAttribute:
[legend]
Collaboration diagram for System.Xml.XmlAttribute:
[legend]

Public Member Functions

override XmlNode CloneNode (bool deep)
 Creates a duplicate of this node. More...
 
override XmlNode InsertBefore (XmlNode newChild, XmlNode refChild)
 Inserts the specified node immediately before the specified reference node. More...
 
override XmlNode InsertAfter (XmlNode newChild, XmlNode refChild)
 Inserts the specified node immediately after the specified reference node. More...
 
override XmlNode ReplaceChild (XmlNode newChild, XmlNode oldChild)
 Replaces the child node specified with the new child node specified. More...
 
override XmlNode RemoveChild (XmlNode oldChild)
 Removes the specified child node. More...
 
override XmlNode PrependChild (XmlNode newChild)
 Adds the specified node to the beginning of the list of child nodes for this node. More...
 
override XmlNode AppendChild (XmlNode newChild)
 Adds the specified node to the end of the list of child nodes, of this node. More...
 
override void WriteTo (XmlWriter w)
 Saves the node to the specified T:System.Xml.XmlWriter. More...
 
override void WriteContentTo (XmlWriter w)
 Saves all the children of the node to the specified T:System.Xml.XmlWriter. More...
 
- Public Member Functions inherited from System.Xml.XmlNode
virtual XPathNavigator CreateNavigator ()
 Creates an T:System.Xml.XPath.XPathNavigator for navigating this object. More...
 
XmlNode SelectSingleNode (string xpath)
 Selects the first XmlNode that matches the XPath expression. More...
 
XmlNode SelectSingleNode (string xpath, XmlNamespaceManager nsmgr)
 Selects the first XmlNode that matches the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied T:System.Xml.XmlNamespaceManager. More...
 
XmlNodeList SelectNodes (string xpath)
 Selects a list of nodes matching the XPath expression. More...
 
XmlNodeList SelectNodes (string xpath, XmlNamespaceManager nsmgr)
 Selects a list of nodes matching the XPath expression. Any prefixes found in the XPath expression are resolved using the supplied T:System.Xml.XmlNamespaceManager. More...
 
virtual void Normalize ()
 Puts all XmlText nodes in the full depth of the sub-tree underneath this XmlNode into a "normal" form where only markup (that is, tags, comments, processing instructions, CDATA sections, and entity references) separates XmlText nodes, that is, there are no adjacent XmlText nodes. More...
 
virtual bool Supports (string feature, string version)
 Tests if the DOM implementation implements a specific feature. More...
 
virtual XmlNode Clone ()
 Creates a duplicate of this node. More...
 
IEnumerator GetEnumerator ()
 Get an enumerator that iterates through the child nodes in the current node. More...
 
virtual void RemoveAll ()
 Removes all the child nodes and/or attributes of the current node. More...
 
virtual string GetNamespaceOfPrefix (string prefix)
 Looks up the closest xmlns declaration for the given prefix that is in scope for the current node and returns the namespace URI in the declaration. More...
 
virtual string GetPrefixOfNamespace (string namespaceURI)
 Looks up the closest xmlns declaration for the given namespace URI that is in scope for the current node and returns the prefix defined in that declaration. More...
 

Public Attributes

override XmlNode ParentNode => null
 Gets the parent of this node. For XmlAttribute nodes, this property always returns null. More...
 
override string Name => name.Name
 Gets the qualified name of the node. More...
 
override string LocalName => name.LocalName
 Gets the local name of the node. More...
 
override string NamespaceURI => name.NamespaceURI
 Gets the namespace URI of this node. More...
 
override XmlNodeType NodeType => XmlNodeType.Attribute
 Gets the type of the current node. More...
 
override XmlDocument OwnerDocument => name.OwnerDocument
 Gets the T:System.Xml.XmlDocument to which this node belongs. More...
 
override IXmlSchemaInfo SchemaInfo => name
 Gets the post-schema-validation-infoset that has been assigned to this node as a result of schema validation. More...
 
virtual bool Specified => true
 Gets a value indicating whether the attribute value was explicitly set. More...
 
virtual XmlElement OwnerElement => parentNode as XmlElement
 Gets the T:System.Xml.XmlElement to which the attribute belongs. More...
 
- Public Attributes inherited from System.Xml.XmlNode
virtual XmlNodeList ChildNodes => new XmlChildNodes(this)
 Gets all the child nodes of the node. More...
 
virtual XmlNode PreviousSibling => null
 Gets the node immediately preceding this node. More...
 
virtual XmlNode NextSibling => null
 Gets the node immediately following this node. More...
 
virtual XmlAttributeCollection Attributes => null
 Gets an T:System.Xml.XmlAttributeCollection containing the attributes of this node. More...
 
virtual XmlNode FirstChild => LastNode?.next
 Gets the first child of the node. More...
 
virtual XmlNode LastChild => LastNode
 Gets the last child of the node. More...
 
virtual bool HasChildNodes => LastNode != null
 Gets a value indicating whether this node has any child nodes. More...
 
virtual string NamespaceURI => string.Empty
 Gets the namespace URI of this node. More...
 
virtual IXmlSchemaInfo SchemaInfo => XmlDocument.NotKnownSchemaInfo
 Gets the post schema validation infoset that has been assigned to this node as a result of schema validation. More...
 
virtual XmlNode PreviousText => null
 Gets the text node that immediately precedes this node. More...
 

Protected Member Functions

internal XmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc)
 Initializes a new instance of the T:System.Xml.XmlAttribute class. More...
 

Properties

override string Prefix [get, set]
 Gets or sets the namespace prefix of this node. More...
 
override string Value [get, set]
 Gets or sets the value of the node. More...
 
override string InnerText [set]
 Sets the concatenated values of the node and all its children. More...
 
override string InnerXml [set]
 Sets the value of the attribute. More...
 
override string BaseURI [get]
 Gets the base Uniform Resource Identifier (URI) of the node. More...
 
- Properties inherited from System.Xml.XmlNode
abstract string Name [get]
 Gets the qualified name of the node, when overridden in a derived class. More...
 
virtual string Value [get, set]
 Gets or sets the value of the node. More...
 
abstract XmlNodeType NodeType [get]
 Gets the type of the current node, when overridden in a derived class. More...
 
virtual XmlNode ParentNode [get]
 Gets the parent of this node (for nodes that can have parents). More...
 
virtual XmlDocument OwnerDocument [get]
 Gets the T:System.Xml.XmlDocument to which this node belongs. More...
 
virtual string Prefix [get, set]
 Gets or sets the namespace prefix of this node. More...
 
abstract string LocalName [get]
 Gets the local name of the node, when overridden in a derived class. More...
 
virtual bool IsReadOnly [get]
 Gets a value indicating whether the node is read-only. More...
 
virtual string InnerText [get, set]
 Gets or sets the concatenated values of the node and all its child nodes. More...
 
virtual string OuterXml [get]
 Gets the markup containing this node and all its child nodes. More...
 
virtual string InnerXml [get, set]
 Gets or sets the markup representing only the child nodes of this node. More...
 
virtual string BaseURI [get]
 Gets the base URI of the current node. More...
 
virtual XmlElement this[string name] [get]
 Gets the first child element with the specified P:System.Xml.XmlNode.Name. More...
 
virtual XmlElement this[string localname, string ns] [get]
 Gets the first child element with the specified P:System.Xml.XmlNode.LocalName and P:System.Xml.XmlNode.NamespaceURI. More...
 

Detailed Description

Represents an attribute. Valid and default values for the attribute are defined in a document type definition (DTD) or schema.

Definition at line 7 of file XmlAttribute.cs.

Constructor & Destructor Documentation

◆ XmlAttribute()

internal System.Xml.XmlAttribute.XmlAttribute ( string  prefix,
string  localName,
string  namespaceURI,
XmlDocument  doc 
)
protected

Initializes a new instance of the T:System.Xml.XmlAttribute class.

Parameters
prefixThe namespace prefix.
localNameThe local name of the attribute.
namespaceURIThe namespace uniform resource identifier (URI).
docThe parent XML document.

Definition at line 226 of file XmlAttribute.cs.

Member Function Documentation

◆ AppendChild()

override XmlNode System.Xml.XmlAttribute.AppendChild ( XmlNode  newChild)
virtual

Adds the specified node to the end of the list of child nodes, of this node.

Parameters
newChildThe T:System.Xml.XmlNode to add.
Returns
The T:System.Xml.XmlNode added.
Exceptions
T:System.InvalidOperationExceptionThis node is of a type that does not allow child nodes of the type of the newChild node.The newChild is an ancestor of this node.
T:System.ArgumentExceptionThe newChild was created from a different document than the one that created this node.This node is read-only.

Reimplemented from System.Xml.XmlNode.

Definition at line 419 of file XmlAttribute.cs.

◆ CloneNode()

override XmlNode System.Xml.XmlAttribute.CloneNode ( bool  deep)
virtual

Creates a duplicate of this node.

Parameters
deeptrue to recursively clone the subtree under the specified node; false to clone only the node itself
Returns
The duplicate node.

Implements System.Xml.XmlNode.

Definition at line 235 of file XmlAttribute.cs.

◆ InsertAfter()

override XmlNode System.Xml.XmlAttribute.InsertAfter ( XmlNode  newChild,
XmlNode  refChild 
)
virtual

Inserts the specified node immediately after the specified reference node.

Parameters
newChildThe T:System.Xml.XmlNode to insert.
refChildThe T:System.Xml.XmlNode that is the reference node. The newChild is placed after the refChild .
Returns
The T:System.Xml.XmlNode inserted.
Exceptions
T:System.InvalidOperationExceptionThis node is of a type that does not allow child nodes of the type of the newChild node.The newChild is an ancestor of this node.
T:System.ArgumentExceptionThe newChild was created from a different document than the one that created this node.The refChild is not a child of this node.This node is read-only.

Reimplemented from System.Xml.XmlNode.

Definition at line 335 of file XmlAttribute.cs.

◆ InsertBefore()

override XmlNode System.Xml.XmlAttribute.InsertBefore ( XmlNode  newChild,
XmlNode  refChild 
)
virtual

Inserts the specified node immediately before the specified reference node.

Parameters
newChildThe T:System.Xml.XmlNode to insert.
refChildThe T:System.Xml.XmlNode that is the reference node. The newChild is placed before this node.
Returns
The T:System.Xml.XmlNode inserted.
Exceptions
T:System.InvalidOperationExceptionThe current node is of a type that does not allow child nodes of the type of the newChild node.The newChild is an ancestor of this node.
T:System.ArgumentExceptionThe newChild was created from a different document than the one that created this node.The refChild is not a child of this node.This node is read-only.

Reimplemented from System.Xml.XmlNode.

Definition at line 313 of file XmlAttribute.cs.

◆ PrependChild()

override XmlNode System.Xml.XmlAttribute.PrependChild ( XmlNode  newChild)
virtual

Adds the specified node to the beginning of the list of child nodes for this node.

Parameters
newChildThe T:System.Xml.XmlNode to add. If it is an T:System.Xml.XmlDocumentFragment, the entire contents of the document fragment are moved into the child list of this node.
Returns
The T:System.Xml.XmlNode added.
Exceptions
T:System.InvalidOperationExceptionThis node is of a type that does not allow child nodes of the type of the newChild node.The newChild is an ancestor of this node.
T:System.ArgumentExceptionThe newChild was created from a different document than the one that created this node.This node is read-only.

Reimplemented from System.Xml.XmlNode.

Definition at line 398 of file XmlAttribute.cs.

◆ RemoveChild()

override XmlNode System.Xml.XmlAttribute.RemoveChild ( XmlNode  oldChild)
virtual

Removes the specified child node.

Parameters
oldChildThe T:System.Xml.XmlNode to remove.
Returns
The T:System.Xml.XmlNode removed.
Exceptions
T:System.ArgumentExceptionThe oldChild is not a child of this node. Or this node is read-only.

Reimplemented from System.Xml.XmlNode.

Definition at line 377 of file XmlAttribute.cs.

◆ ReplaceChild()

override XmlNode System.Xml.XmlAttribute.ReplaceChild ( XmlNode  newChild,
XmlNode  oldChild 
)
virtual

Replaces the child node specified with the new child node specified.

Parameters
newChildThe new child T:System.Xml.XmlNode.
oldChildThe T:System.Xml.XmlNode to replace.
Returns
The T:System.Xml.XmlNode replaced.
Exceptions
T:System.InvalidOperationExceptionThis node is of a type that does not allow child nodes of the type of the newChild node.The newChild is an ancestor of this node.
T:System.ArgumentExceptionThe newChild was created from a different document than the one that created this node.This node is read-only.The oldChild is not a child of this node.

Reimplemented from System.Xml.XmlNode.

Definition at line 357 of file XmlAttribute.cs.

◆ WriteContentTo()

override void System.Xml.XmlAttribute.WriteContentTo ( XmlWriter  w)
virtual

Saves all the children of the node to the specified T:System.Xml.XmlWriter.

Parameters
wThe XmlWriter to which you want to save.

Implements System.Xml.XmlNode.

Definition at line 446 of file XmlAttribute.cs.

◆ WriteTo()

override void System.Xml.XmlAttribute.WriteTo ( XmlWriter  w)
virtual

Saves the node to the specified T:System.Xml.XmlWriter.

Parameters
wThe XmlWriter to which you want to save.

Implements System.Xml.XmlNode.

Definition at line 437 of file XmlAttribute.cs.

Member Data Documentation

◆ LocalName

override string System.Xml.XmlAttribute.LocalName => name.LocalName

Gets the local name of the node.

Returns
The name of the attribute node with the prefix removed. In the following example <book bk:genre= 'novel'>, the LocalName of the attribute is genre.

Definition at line 37 of file XmlAttribute.cs.

◆ Name

override string System.Xml.XmlAttribute.Name => name.Name

Gets the qualified name of the node.

Returns
The qualified name of the attribute node.

Definition at line 33 of file XmlAttribute.cs.

◆ NamespaceURI

override string System.Xml.XmlAttribute.NamespaceURI => name.NamespaceURI

Gets the namespace URI of this node.

Returns
The namespace URI of this node. If the attribute is not explicitly given a namespace, this property returns String.Empty.

Definition at line 41 of file XmlAttribute.cs.

◆ NodeType

override XmlNodeType System.Xml.XmlAttribute.NodeType => XmlNodeType.Attribute

Gets the type of the current node.

Returns
The node type for XmlAttribute nodes is XmlNodeType.Attribute.

Definition at line 61 of file XmlAttribute.cs.

◆ OwnerDocument

override XmlDocument System.Xml.XmlAttribute.OwnerDocument => name.OwnerDocument

Gets the T:System.Xml.XmlDocument to which this node belongs.

Returns
An XML document to which this node belongs.

Definition at line 65 of file XmlAttribute.cs.

◆ OwnerElement

virtual XmlElement System.Xml.XmlAttribute.OwnerElement => parentNode as XmlElement

Gets the T:System.Xml.XmlElement to which the attribute belongs.

Returns
The XmlElement that the attribute belongs to or null if this attribute is not part of an XmlElement.

Definition at line 126 of file XmlAttribute.cs.

◆ ParentNode

override XmlNode System.Xml.XmlAttribute.ParentNode => null

Gets the parent of this node. For XmlAttribute nodes, this property always returns null.

Returns
For XmlAttribute nodes, this property always returns null.

Definition at line 29 of file XmlAttribute.cs.

◆ SchemaInfo

override IXmlSchemaInfo System.Xml.XmlAttribute.SchemaInfo => name

Gets the post-schema-validation-infoset that has been assigned to this node as a result of schema validation.

Returns
An T:System.Xml.Schema.IXmlSchemaInfo containing the post-schema-validation-infoset of this node.

Definition at line 84 of file XmlAttribute.cs.

◆ Specified

virtual bool System.Xml.XmlAttribute.Specified => true

Gets a value indicating whether the attribute value was explicitly set.

Returns
true if this attribute was explicitly given a value in the original instance document; otherwise, false. A value of false indicates that the value of the attribute came from the DTD.

Definition at line 122 of file XmlAttribute.cs.

Property Documentation

◆ BaseURI

override string System.Xml.XmlAttribute.BaseURI
get

Gets the base Uniform Resource Identifier (URI) of the node.

Returns
The location from which the node was loaded or String.Empty if the node has no base URI. Attribute nodes have the same base URI as their owner element. If an attribute node does not have an owner element, BaseURI returns String.Empty.

Definition at line 144 of file XmlAttribute.cs.

◆ InnerText

override string System.Xml.XmlAttribute.InnerText
set

Sets the concatenated values of the node and all its children.

Returns
The concatenated values of the node and all its children. For attribute nodes, this property has the same functionality as the P:System.Xml.XmlAttribute.Value property.

Definition at line 89 of file XmlAttribute.cs.

◆ InnerXml

override string System.Xml.XmlAttribute.InnerXml
set

Sets the value of the attribute.

Returns
The attribute value.
Exceptions
T:System.Xml.XmlExceptionThe XML specified when setting this property is not well-formed.

Definition at line 132 of file XmlAttribute.cs.

◆ Prefix

override string System.Xml.XmlAttribute.Prefix
getset

Gets or sets the namespace prefix of this node.

Returns
The namespace prefix of this node. If there is no prefix, this property returns String.Empty.
Exceptions
T:System.ArgumentExceptionThis node is read-only.
T:System.Xml.XmlExceptionThe specified prefix contains an invalid character.The specified prefix is malformed.The namespaceURI of this node is null.The specified prefix is "xml", and the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace".This node is an attribute, the specified prefix is "xmlns", and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/".This node is an attribute, and the qualifiedName of this node is "xmlns" [Namespaces].

Definition at line 48 of file XmlAttribute.cs.

◆ Value

override string System.Xml.XmlAttribute.Value
getset

Gets or sets the value of the node.

Returns
The value returned depends on the P:System.Xml.XmlNode.NodeType of the node. For XmlAttribute nodes, this property is the value of attribute.
Exceptions
T:System.ArgumentExceptionThe node is read-only and a set operation is called.

Definition at line 71 of file XmlAttribute.cs.


The documentation for this class was generated from the following file: