指定した名前空間 URI に関連付けられている XmlSchema を取得します。
[C#] C# では、このプロパティは XmlSchemaCollection クラスのインデクサになります。
Public Default ReadOnly Property Item( _
ByVal ns As String _) As XmlSchema
[C#]
public XmlSchema this[stringns] {get;}
[C++]
public: __property XmlSchema* get_Item(String* ns);
[JScript]
returnValue = XmlSchemaCollectionObject.Item(ns);またはreturnValue = XmlSchemaCollectionObject(ns);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- ns
返すスキーマに関連付けられている名前空間 URI。通常、これはそのスキーマの targetNamespace です。
パラメータ [Visual Basic, C#, C++]
- ns
返すスキーマに関連付けられている名前空間 URI。通常、これはそのスキーマの targetNamespace です。
プロパティ値
名前空間 URI に関連付けられている XmlSchema 。指定した名前空間に関連付けられているスキーマが読み込まれていないか、名前空間が XDR スキーマに関連付けられている場合は null 参照 (Visual Basic では Nothing) 。
使用例
[Visual Basic, C#, C++] スキーマがコレクション内に存在するかどうかを確認する例を次に示します。コレクション内に存在する場合は、そのスキーマを表示します。
If xsc.Contains("urn:bookstore-schema") Then
Dim schema As XmlSchema = xsc("urn:bookstore-schema")
Dim sw As New StringWriter()
Dim xmlWriter As New XmlTextWriter(sw)
xmlWriter.Formatting = Formatting.Indented
xmlWriter.Indentation = 2
schema.Write(xmlWriter)
Console.WriteLine(sw.ToString())
End If
[C#]
if (xsc.Contains("urn:bookstore-schema"))
{
XmlSchema schema = xsc["urn:bookstore-schema"];
StringWriter sw = new StringWriter();
XmlTextWriter xmlWriter = new XmlTextWriter(sw);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.Indentation = 2;
schema.Write(xmlWriter);
Console.WriteLine(sw.ToString());
}
[C++]
if (xsc->Contains(S"urn:bookstore-schema"))
{
XmlSchema* schema = xsc->Item[S"urn:bookstore-schema"];
StringWriter* sw = new StringWriter();
XmlTextWriter* xmlWriter = new XmlTextWriter(sw);
xmlWriter->Formatting = Formatting::Indented;
xmlWriter->Indentation = 2;
schema->Write(xmlWriter);
Console::WriteLine(sw);
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
XmlSchemaCollection クラス | XmlSchemaCollection メンバ | System.Xml.Schema 名前空間