XmlAttribute.Prefix プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
このノードの名前空間プレフィックスを取得または設定します。
public:
virtual property System::String ^ Prefix { System::String ^ get(); void set(System::String ^ value); };
public override string Prefix { get; set; }
member this.Prefix : string with get, set
Public Overrides Property Prefix As String
プロパティ値
このノードの名前空間プレフィックス。 プレフィックスがない場合、このプロパティは String.Empty を返します。
例外
このノードは読み取り専用です。
指定したプレフィックスに無効な文字が含まれています。
指定したプレフィックスの形式が正しくありません。
このノードの namespaceURI は null。
指定したプレフィックスは "xml" で、このノードの namespaceURI は "http://www.w3.org/XML/1998/namespace" とは異なります。
このノードは属性であり、指定されたプレフィックスは "xmlns" で、このノードの namespaceURI は "http://www.w3.org/2000/xmlns/" とは異なります。
このノードは属性であり、このノードの qualifiedName は "xmlns" [Namespaces] です。
例
次の例では、属性コレクション内の各ノードに関する情報を表示します。
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);
}
}
}
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
注釈
属性のプレフィックスを変更しても名前空間 URI は変更されないため、既定値が設定されていることがわかっている属性のプレフィックスを変更しても、既定値と元のプレフィックスを持つ新しい属性は作成されません。