다음을 통해 공유


방법: 네임스페이스 접두사 제어(Visual Basic)(LINQ to XML)

이 항목에서는 네임스페이스 접두사를 제어하는 방법에 대해 설명합니다.

예제

설명

이 예제에서는 두 네임스페이스를 선언한 다음 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>

참고 항목

개념

Visual Basic의 네임스페이스(LINQ to XML)