XmlNamespaceManager.PopScope メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlNamespaceManager.PopScope メソッドの意味・解説 

XmlNamespaceManager.PopScope メソッド

名前空間スコープスタックからポップます。

名前空間: System.Xml
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

解説解説

このメソッド呼び出すと、AddNamespace を呼び出すことによって最後PopScope呼び出し以降 XmlNamespaceManager に追加されすべての名前空間削除されます。

使用例使用例

プリフィックス名前空間ペアXmlNamespaceManager追加してから、コレクション内のすべてのペア表示する例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        Dim test As New
 Sample()
    End Sub 'Main
    
    Public Sub New()
        ' Create the XmlNamespaceManager.
        Dim nt As New NameTable()
        Dim nsmgr As New
 XmlNamespaceManager(nt)
        
        ' Add prefix/namespace pairs to the XmlNamespaceManager.
        nsmgr.AddNamespace("", "www.wideworldimporters.com")
 'Adds a default namespace.
        nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe")
        nsmgr.PushScope() 'Pushes a namespace scope on the stack.
        nsmgr.AddNamespace("", "www.lucernepublishing.com")
 'Adds another default namespace.
        nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners")
        
        Console.WriteLine("Show all the prefix/namespace pairs
 in the XmlNamespaceManager...")
        ShowAllNamespaces(nsmgr)
    End Sub 'New
    
    
    Private Sub ShowAllNamespaces(nsmgr As
 XmlNamespaceManager)
        Do
            Dim prefix As String
            For Each prefix In
  nsmgr
                Console.WriteLine("Prefix={0}, Namespace={1}",
 prefix, nsmgr.LookupNamespace(prefix))
            Next prefix
        Loop While nsmgr.PopScope()
    End Sub 'ShowAllNamespaces
End Class 'Sample
using System;
using System.IO;
using System.Xml;


public class Sample
{
  public static void Main()
  {
    Sample test = new Sample();
  }
  public Sample()
  {
    // Create the XmlNamespaceManager.
    NameTable nt = new NameTable();
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

    // Add prefix/namespace pairs to the XmlNamespaceManager.
    nsmgr.AddNamespace("", "www.wideworldimporters.com"); //Adds
 a default namespace.
    nsmgr.AddNamespace("europe", "www.wideworldimporters.com/europe");
    nsmgr.PushScope();  //Pushes a namespace scope on the stack.
    nsmgr.AddNamespace("", "www.lucernepublishing.com"); //Adds
 another default namespace.
    nsmgr.AddNamespace("partners", "www.lucernepublishing.com/partners");

    Console.WriteLine("Show all the prefix/namespace pairs
 in the XmlNamespaceManager...");
    ShowAllNamespaces(nsmgr);
  }

  private void ShowAllNamespaces(XmlNamespaceManager
 nsmgr)
  {
    do{
       foreach (String prefix in nsmgr)
       {
        Console.WriteLine("Prefix={0}, Namespace={1}", prefix,nsmgr.LookupNamespace(prefix));
       } 
    }
    while (nsmgr.PopScope());
  }
}
#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
public ref class Sample
{
public:
   Sample()
   {
      
      // Create the XmlNamespaceManager.
      NameTable^ nt = gcnew NameTable;
      XmlNamespaceManager^ nsmgr = gcnew XmlNamespaceManager( nt );
      
      // Add prefix/namespace pairs to the XmlNamespaceManager.
      nsmgr->AddNamespace( "", "www.wideworldimporters.com"
 ); //Adds a default namespace.
      nsmgr->AddNamespace( "europe", "www.wideworldimporters.com/europe"
 );
      nsmgr->PushScope(); //Pushes a namespace scope on the stack.
      nsmgr->AddNamespace( "", "www.lucernepublishing.com"
 ); //Adds another default namespace.
      nsmgr->AddNamespace( "partners", "www.lucernepublishing.com/partners"
 );
      Console::WriteLine( "Show all the prefix/namespace
 pairs in the XmlNamespaceManager..." );
      ShowAllNamespaces( nsmgr );
   }


private:
   void ShowAllNamespaces( XmlNamespaceManager^ nsmgr )
   {
      do
      {
         System::Collections::IEnumerator^ myEnum = nsmgr->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            String^ prefix = safe_cast<String^>(myEnum->Current);
            Console::WriteLine( "Prefix={0}, Namespace={1}", prefix, nsmgr->LookupNamespace(
 prefix ) );
         }
      }
      while ( nsmgr->PopScope() );
   }

};

int main()
{
   gcnew Sample;
}

import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{
    public static void main(String[]
 args)
    {
        Sample test = new Sample();
    } //main

    public Sample()
    {
        // Create the XmlNamespaceManager.
        NameTable nT = new NameTable();
        XmlNamespaceManager nsMgr = new XmlNamespaceManager(nT);

        // Add prefix/namespace pairs to the XmlNamespaceManager.
        //Adds a default namespace.
        nsMgr.AddNamespace("", "www.wideworldimporters.com");
 
        nsMgr.AddNamespace("europe", "www.wideworldimporters.com/europe");
        nsMgr.PushScope(); //Pushes a namespace scope on the stack.

        //Adds another default namespace.
        nsMgr.AddNamespace("", "www.lucernepublishing.com");
 
        nsMgr.AddNamespace("partners", "www.lucernepublishing.com/partners");
        Console.WriteLine("Show all the prefix/namespace
 pairs in the " 
            + "XmlNamespaceManager...");
        ShowAllNamespaces(nsMgr);
    } //Sample

    private void ShowAllNamespaces(XmlNamespaceManager
 nsMgr)
    {
        do {
            String prefix;
            System.Collections.IEnumerator objEnum = nsMgr.GetEnumerator();
            while (objEnum.MoveNext()) {
                prefix = objEnum.get_Current().ToString();
                Console.WriteLine("Prefix={0}, Namespace={1}", prefix,
 
                    nsMgr.LookupNamespace(prefix));
            }
        } while (nsMgr.PopScope());
    } //ShowAllNamespaces
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlNamespaceManager クラス
XmlNamespaceManager メンバ
System.Xml 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からXmlNamespaceManager.PopScope メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からXmlNamespaceManager.PopScope メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からXmlNamespaceManager.PopScope メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

XmlNamespaceManager.PopScope メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlNamespaceManager.PopScope メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS