Cómo controlar prefijos de espacios de nombres (Visual Basic) (LINQ to XML)
Actualización: November 2007
En este tema se describe cómo puede controlar prefijos de espacios de nombres.
Ejemplo
Descripción
Este ejemplo declara dos espacios de nombre. Especifica que el espacio de nombres https://www.adventure-works.com tiene el prefijo aw y que el espacio de nombres www.fourthcoffee.com tiene el prefijo fc.
Código
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
Comentarios
Este ejemplo genera el siguiente resultado:
<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>