Vorgehensweise: Steuern von Namespacepräfixen (Visual Basic) (LINQ to XML)
In diesem Thema wird beschrieben, wie Sie Namespacepräfixe steuern können.
Beispiel
Beschreibung
Dieses Beispiel deklariert zwei Namespaces.Es gibt für den http://www.adventure-works.com-Namespace das Präfix aw und für den www.fourthcoffee.com -Namespace das Präfix fc an.
Code
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
Kommentare
Dieses Beispiel führt zur folgenden Ausgabe:
<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>