XmlNotation.NodeType 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得目前節點的類型。
public:
virtual property System::Xml::XmlNodeType NodeType { System::Xml::XmlNodeType get(); };
public override System.Xml.XmlNodeType NodeType { get; }
member this.NodeType : System.Xml.XmlNodeType
Public Overrides ReadOnly Property NodeType As XmlNodeType
屬性值
節點類型。 如果是 XmlNotation
節點,則這個值會是 XmlNodeType.Notation。
範例
下列範例會顯示 XML 檔中所宣告之標記法的資訊。
#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( " {0} ", note->NodeType );
Console::Write( " {0} ", note->Name );
Console::Write( " {0} ", note->PublicId );
Console::Write( " {0} ", note->SystemId );
Console::WriteLine();
}
}
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->Load( "doment.xml" );
Console::WriteLine( "Display information on all notations..." );
XmlNamedNodeMap^ nMap = doc->DocumentType->Notations;
DisplayNotations( nMap );
}
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();
}
}
}
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
此範例會使用 檔案 doment.xml
作為輸入。
<!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>