このトピックでは、名前空間プレフィックスを制御する方法について説明します。
例
説明
この例では、2 つの名前空間を宣言します。 https://www.adventure-works.com 名前空間のプレフィックスを aw と指定し、www.fourthcoffee.com 名前空間のプレフィックスを fc と指定します。
コード
Imports <xmlns:aw="https://www.adventure-works.com">
Imports <xmlns:fc="www.fourthcoffee.com">
Module Module1
Sub Main()
Dim root As XElement = _
<aw:Root>
<fc:Child>
<aw:DifferentChild>other content</aw:DifferentChild>
</fc:Child>
<aw:Child2>c2 content</aw:Child2>
<fc:Child3>c3 content</fc:Child3>
</aw:Root>
Console.WriteLine(root)
End Sub
End Module
コメント
この例では次の出力が生成されます。
<aw:Root xmlns:fc="www.fourthcoffee.com" xmlns:aw="https://www.adventure-works.com">
<fc:Child>
<aw:DifferentChild>other content</aw:DifferentChild>
</fc:Child>
<aw:Child2>c2 content</aw:Child2>
<fc:Child3>c3 content</fc:Child3>
</aw:Root>