XmlValidatingReader.EntityHandling プロパティ
アセンブリ: System.Xml (system.xml.dll 内)

Dim instance As XmlValidatingReader Dim value As EntityHandling value = instance.EntityHandling instance.EntityHandling = value
public: property EntityHandling EntityHandling { EntityHandling get (); void set (EntityHandling value); }
/** @property */ public EntityHandling get_EntityHandling () /** @property */ public void set_EntityHandling (EntityHandling value)
public function get EntityHandling () : EntityHandling public function set EntityHandling (value : EntityHandling)
EntityHandling 値の 1 つ。EntityHandling が指定されていない場合は、既定で EntityHandling.ExpandEntities が使用されます。


![]() |
---|
Microsoft .NET Framework version 2.0 では、XmlValidatingReader クラスは使用されなくなりました。検証を実行する XmlReader のインスタンスは、XmlReaderSettings クラスおよび Create メソッドを使用して作成できます。詳細については、「XmlReader による XML データの検証」を参照してください。 |
このプロパティは変更することもでき、変更は次に Read を呼び出した後に有効になります。
EntityHandling を ExpandCharEntities に設定すると、属性値の一部だけが正規化されます。リーダーは、隣接するエンティティ参照ノードの内容とは関係なく、個別のテキスト ノードを正規化します。
EntityHandling を ExpandEntities に設定すると、"doc" 要素ノードに、展開したエンティティ テキストを持つ 1 つのテキスト ノードが含まれます。
EntityHandling を ExpandCharEntites に設定し、WhitespaceHandling を Significant または All に設定すると、"doc" 要素は、文字エンティティを展開し、一般エンティティをノードとして返します。

ResolveEntity メソッドを使用して、一般エンティティを展開する例を次に示します。
Option Strict Option Explicit Imports System Imports System.IO Imports System.Xml Public Class Sample Public Shared Sub Main() Dim reader As XmlValidatingReader = Nothing Dim txtreader As XmlTextReader = Nothing Try 'Create and load the XmlTextReader with the XML file. txtreader = New XmlTextReader("book1.xml") txtreader.WhitespaceHandling = WhitespaceHandling.None 'Create the XmlValidatingReader over the XmlTextReader. 'Set the reader to not expand general entities. reader = New XmlValidatingReader(txtreader) reader.ValidationType = ValidationType.None reader.EntityHandling = EntityHandling.ExpandCharEntities reader.MoveToContent() 'Move to the root element. reader.Read() 'Move to title start tag. reader.Skip() 'Skip the title element. 'Read the misc start tag. The reader is now positioned on 'the entity reference node. reader.ReadStartElement() 'Because EntityHandling is set to ExpandCharEntities, you must call 'ResolveEntity to expand the entity. The entity replacement text is 'then parsed and returned as a child node. Console.WriteLine("Expand the entity...") reader.ResolveEntity() Console.WriteLine("The entity replacement text is returned as a text node.") reader.Read() Console.WriteLine("NodeType: {0} Value: {1}", reader.NodeType, reader.Value) Console.WriteLine("An EndEntity node closes the entity reference scope.") reader.Read() Console.WriteLine("NodeType: {0} Name: {1}", reader.NodeType, reader.Name) Finally If Not (reader Is Nothing) Then reader.Close() End If End Try End Sub 'Main
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { XmlValidatingReader reader = null; XmlTextReader txtreader = null; try { //Create and load the XmlTextReader with the XML file. txtreader = new XmlTextReader("book1.xml"); txtreader.WhitespaceHandling = WhitespaceHandling.None; //Create the XmlValidatingReader over the XmlTextReader. //Set the reader to not expand general entities. reader = new XmlValidatingReader(txtreader); reader.ValidationType = ValidationType.None; reader.EntityHandling = EntityHandling.ExpandCharEntities; reader.MoveToContent(); //Move to the root element. reader.Read(); //Move to title start tag. reader.Skip(); //Skip the title element. //Read the misc start tag. The reader is now positioned on //the entity reference node. reader.ReadStartElement(); //Because EntityHandling is set to ExpandCharEntities, you must call //ResolveEntity to expand the entity. The entity replacement text is //then parsed and returned as a child node. Console.WriteLine("Expand the entity..."); reader.ResolveEntity(); Console.WriteLine("The entity replacement text is returned as a text node."); reader.Read(); Console.WriteLine("NodeType: {0} Value: {1}", reader.NodeType ,reader.Value); Console.WriteLine("An EndEntity node closes the entity reference scope."); reader.Read(); Console.WriteLine("NodeType: {0} Name: {1}", reader.NodeType,reader.Name); } finally { if (reader != null) reader.Close(); } } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { XmlValidatingReader^ reader = nullptr; XmlTextReader^ txtreader = nullptr; try { //Create and load the XmlTextReader with the XML file. txtreader = gcnew XmlTextReader( "book1.xml" ); txtreader->WhitespaceHandling = WhitespaceHandling::None; //Create the XmlValidatingReader over the XmlTextReader. //Set the reader to not expand general entities. reader = gcnew XmlValidatingReader( txtreader ); reader->ValidationType = ValidationType::None; reader->EntityHandling = EntityHandling::ExpandCharEntities; reader->MoveToContent(); //Move to the root element. reader->Read(); //Move to title start tag. reader->Skip(); //Skip the title element. //Read the misc start tag. The reader is now positioned on //the entity reference node. reader->ReadStartElement(); //Because EntityHandling is set to ExpandCharEntities, you must call //ResolveEntity to expand the entity. The entity replacement text is //then parsed and returned as a child node. Console::WriteLine( "Expand the entity..." ); reader->ResolveEntity(); Console::WriteLine( "The entity replacement text is returned as a text node." ); reader->Read(); Console::WriteLine( "NodeType: {0} Value: {1}", reader->NodeType, reader->Value ); Console::WriteLine( "An EndEntity node closes the entity reference scope." ); reader->Read(); Console::WriteLine( "NodeType: {0} Name: {1}", reader->NodeType, reader->Name ); } finally { if ( reader != nullptr ) reader->Close(); } }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { XmlValidatingReader reader = null; XmlTextReader txtReader = null; try { //Create and load the XmlTextReader with the XML file. txtReader = new XmlTextReader("book1.xml"); txtReader.set_WhitespaceHandling(WhitespaceHandling.None); //Create the XmlValidatingReader over the XmlTextReader. //Set the reader to not expand general entities. reader = new XmlValidatingReader(txtReader); reader.set_ValidationType(ValidationType.None); reader.set_EntityHandling(EntityHandling.ExpandCharEntities); reader.MoveToContent(); //Move to the root element. reader.Read(); //Move to title start tag. reader.Skip(); //Skip the title element. //Read the misc start tag. The reader is now positioned on //the entity reference node. reader.ReadStartElement(); //Because EntityHandling is set to ExpandCharEntities, you //must call ResolveEntity to expand the entity. The entity //replacement text is then parsed and returned as a child node. Console.WriteLine("Expand the entity..."); reader.ResolveEntity(); Console.WriteLine("The entity replacement text is " + "returned as a text node."); reader.Read(); Console.WriteLine("NodeType: {0} Value: {1}", reader.get_NodeType(), reader.get_Value()); Console.WriteLine("An EndEntity node closes the entity " + " reference scope."); reader.Read(); Console.WriteLine("NodeType: {0} Name: {1}", reader.get_NodeType() , reader.get_Name()); } finally { if (reader != null) { reader.Close(); } } } //main } //Sample

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlValidatingReader.EntityHandling プロパティを検索する場合は、下記のリンクをクリックしてください。

- XmlValidatingReader.EntityHandling プロパティのページへのリンク