XmlAttribute.Value-Eigenschaft
Ruft den Wert des Knotens ab oder legt diesen fest.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public Overrides Property Value As String
'Usage
Dim instance As XmlAttribute
Dim value As String
value = instance.Value
instance.Value = value
public override string Value { get; set; }
public:
virtual property String^ Value {
String^ get () override;
void set (String^ value) override;
}
/** @property */
public String get_Value ()
/** @property */
public void set_Value (String value)
public override function get Value () : String
public override function set Value (value : String)
Eigenschaftenwert
Der zurückgegebene Wert hängt vom NodeType des Knotens ab. Bei XmlAttribute-Knoten ist diese Eigenschaft der Wert des Attributs.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der Knoten ist schreibgeschützt, und ein Set-Vorgang wird aufgerufen. |
Beispiel
Im folgenden Beispiel werden Informationen über die einzelnen Knoten in der Attributauflistung angezeigt.
Imports System
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>")
'Create an attribute collection.
Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes
Console.WriteLine("Display information on each of the attributes... ")
Dim attr as XmlAttribute
for each attr in attrColl
Console.Write("{0}:{1} = {2}", attr.Prefix, attr.LocalName, attr.Value)
Console.WriteLine(" namespaceURI=" + attr.NamespaceURI)
next
end sub
end class
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main(){
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
//Create an attribute collection.
XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;
Console.WriteLine("Display information on each of the attributes... \r\n");
foreach (XmlAttribute attr in attrColl){
Console.Write("{0}:{1} = {2}", attr.Prefix, attr.LocalName, attr.Value);
Console.WriteLine("\t namespaceURI=" + attr.NamespaceURI);
}
}
}
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->LoadXml( "<book xmlns:bk='urn:samples' bk:genre='novel'><title>Pride And Prejudice</title></book>" );
//Create an attribute collection.
XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
Console::WriteLine( "Display information on each of the attributes... \r\n" );
System::Collections::IEnumerator^ myEnum = attrColl->GetEnumerator();
while ( myEnum->MoveNext() )
{
XmlAttribute^ attr = safe_cast<XmlAttribute^>(myEnum->Current);
Console::Write( "{0}:{1} = {2}", attr->Prefix, attr->LocalName, attr->Value );
Console::WriteLine( "\t namespaceURI={0}", attr->NamespaceURI );
}
}
import System.*;
import System.IO.*;
import System.Xml.*;
public class Sample
{
public static void main(String[] args)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book xmlns:bk='urn:samples' bk:genre='novel'>"
+ "<title>Pride And Prejudice</title>"
+ "</book>");
//Create an attribute collection.
XmlAttributeCollection attrColl =
doc.get_DocumentElement().get_Attributes();
Console.WriteLine("Display information on each of the"
+ " attributes... \r\n");
for (int iCtr = 0; iCtr < attrColl.get_Count(); iCtr++) {
XmlAttribute attr = attrColl.get_ItemOf(iCtr);
Console.Write("{0}:{1} = {2}", attr.get_Prefix(),
attr.get_LocalName(), attr.get_Value());
Console.WriteLine("\t namespaceURI=" + attr.get_NamespaceURI());
}
} //main
} //Sample
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
XmlAttribute-Klasse
XmlAttribute-Member
System.Xml-Namespace