Microsoft.xmldom getattribute




















Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services. Privacy policy. Thank you. Microsoft makes no warranties, express or implied, with respect to the information provided here. The name of the attribute to retrieve. This is a qualified name. It is matched against the Name property of the matching node. The value of the specified attribute. An empty string is returned if a matching attribute is not found or if the attribute does not have a specified or default value.

Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. If you want all the attributes of an element node put into a collection, call the XmlElement. Attributes property. This gets the XmlAttributeCollection that contains all the attributes of an element. Therefore, the methods and properties available on the collection include those available on a named node map in addition to methods and properties specific to the XmlAttributeCollection class, such as the ItemOf property or the Append method.

Each item in the attribute collection represents an XmlAttribute node. To find the number of attributes on an element, get the XmlAttributeCollection , and use the Count property to see how many XmlAttribute nodes are in the collection. The following code example shows how to retrieve an attribute collection and, using the Count method for the looping index, iterate over it. The code then shows how to retrieve a single attribute from the collection and display its value.

The information in an attribute collection can be retrieved by name or index number. The example above shows how to retrieve data by name. The next example shows how to retrieve data by index number. Because the XmlAttributeCollection is a collection and can be iterated over by name or index, this example shows selecting the first attribute out of the collection using a zero-based index and using the following file, baseuri.

To retrieve a single attribute node from an element, the XmlElement. GetAttributeNode method is used. It returns an object of type XmlAttribute. Once you have an XmlAttribute , all the methods and properties available in the System. XmlAttribute class are available on that object, such as finding the OwnerElement. You can also do as shown in the previous example, where a single attribute node is retrieved from the attribute collection. The following code example shows how one line of code can be written to retrieve a single attribute by index number from the root of the XML document tree, also known as the DocumentElement property.

Skip to main content.



0コメント

  • 1000 / 1000