NodeType Property
Collapse the table of content
Expand the table of content

XmlNotation.NodeType Property

Gets the type of the current node.

[Visual Basic]
Overrides Public ReadOnly Property NodeType As XmlNodeType
[C#]
public override XmlNodeType NodeType {get;}
[C++]
public: __property XmlNodeType get_NodeType();
[JScript]
public override function get NodeType() : XmlNodeType;

Property Value

The node type. For XmlNotation nodes, the value is XmlNodeType.Notation.

Example

[Visual Basic, C#, C++] The following example displays information on the notations declared in the XML document.

[Visual Basic] 
Imports System
Imports System.IO
Imports System.Xml
 
public class Sample

  private const filename as String = "doment.xml"
 
  public shared sub Main()
    Dim doc as XmlDocument = new XmlDocument()
    doc.Load(filename)

    Console.WriteLine("Display information on all notations...")     
    Dim nMap as XmlNamedNodeMap = doc.DocumentType.Notations
    DisplayNotations(nMap)      
  end sub
 
  public shared sub DisplayNotations(nMap as XmlNamedNodeMap)
     Dim i as integer   
     for i = 0 to nMap.Count - 1
        Dim note as XmlNotation = CType(nMap.Item(i), XmlNotation)
        Console.Write("{0} ", note.NodeType)
        Console.Write("{0} ", note.Name)
        Console.Write("{0} ", note.PublicId)
        Console.Write("{0} ", note.SystemId)
        Console.WriteLine()
     next
  end sub            
end class

[C#] 
using System;
using System.IO;
using System.Xml;
 
public class Sample
{
  private const String filename = "doment.xml";
 
  public static void Main()
  {      
    XmlDocument doc = new XmlDocument();
    doc.Load(filename);

    Console.WriteLine("Display information on all notations...");     
    XmlNamedNodeMap nMap = doc.DocumentType.Notations;
    DisplayNotations(nMap);      
  }
 
  public static void DisplayNotations(XmlNamedNodeMap nMap)
  {   
     for (int i=0; i < nMap.Count; i++)
     {
        XmlNotation note = (XmlNotation) nMap.Item(i);
        Console.Write("{0} ", note.NodeType);
        Console.Write("{0} ", note.Name);
        Console.Write("{0} ", note.PublicId);
        Console.Write("{0} ", note.SystemId);
        Console.WriteLine();
    }
  }            
}

[C++] 
#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;

void DisplayNotations(XmlNamedNodeMap * nMap)
{
   for (int i = 0; i < nMap -> Count; i++) 
   {
      XmlNotation * note = dynamic_cast<XmlNotation*>(nMap -> Item(i));
      Console::Write(S" {0} ", __box(note -> NodeType));
      Console::Write(S" {0} ", note -> Name);
      Console::Write(S" {0} ", note -> PublicId);
      Console::Write(S" {0} ", note -> SystemId);
      Console::WriteLine();
   }
}            

int main() 
{
   XmlDocument* doc = new XmlDocument();
   doc -> Load(S"doment.xml");

   Console::WriteLine(S"Display information on all notations...");     
   XmlNamedNodeMap * nMap = doc -> DocumentType -> Notations;
   DisplayNotations(nMap);      
}

The example uses the file, doment.xml, as input.

<!DOCTYPE doc [

  <!ELEMENT doc ANY>
 
  <!NOTATION w SYSTEM "wine.exe">
  <!NOTATION v PUBLIC "vine.exe">

  <!NOTATION jpg PUBLIC "Jpeg picture format">
  <!NOTATION gif SYSTEM "Gif picture format">

  <!ENTITY wn PUBLIC "http://www.cohowinery.com" "coho.exe" NDATA w>
  <!ENTITY vn SYSTEM "http://www.cohovineyard.com" NDATA v>
  <!ENTITY mytxt "Text Sample">

  <!ATTLIST doc 
        src     ENTITY         #IMPLIED
        srcs    ENTITIES       #IMPLIED
        jpgPic  NOTATION (jpg) #IMPLIED
        gifPic  NOTATION (gif) #REQUIRED>
]>

<doc jpgPic="jpg" gifPic="gif" srcs="vn wn">
    something
</doc>

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

XmlNotation Class | XmlNotation Members | System.Xml Namespace | XmlNodeType

Show:
© 2016 Microsoft