获取当前节点的类型。Gets the type of the current node.

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

属性值

XmlNodeType 值之一,表示当前节点的类型。One of the XmlNodeType values representing the type of the current node.

示例

下面的示例读取一个 XML 并显示每个节点。The following example reads an XML and displays each of the nodes.

#using

using namespace System;

using namespace System::IO;

using namespace System::Xml;

int main()

{

String^ filename = "items.xml";

XmlNodeReader^ reader = nullptr;

try

{

//Create an XmlNodeReader to read the XmlDocument.

XmlDocument^ doc = gcnew XmlDocument;

doc->Load( filename );

reader = gcnew XmlNodeReader( doc );

//Parse the file and display each of the nodes.

while ( reader->Read() )

{

switch ( reader->NodeType )

{

case XmlNodeType::Element:

Console::Write( "", reader->Name );

break;

case XmlNodeType::Text:

Console::Write( reader->Value );

break;

case XmlNodeType::CDATA:

Console::Write( reader->Value );

break;

case XmlNodeType::ProcessingInstruction:

Console::Write( "{0} {1}?>", reader->Name, reader->Value );

break;

case XmlNodeType::Comment:

Console::Write( "", reader->Value );

break;

case XmlNodeType::XmlDeclaration:

Console::Write( "<?xml version='1.0'?>" );

break;

case XmlNodeType::Document:

break;

case XmlNodeType::EndElement:

Console::Write( "{0}>", reader->Name );

break;

}

}

}

finally

{

if ( reader != nullptr )

reader->Close();

}

}using System;

using System.IO;

using System.Xml;

public class Sample

{

private const String filename = "items.xml";

public static void Main()

{

XmlNodeReader reader = null;

try

{

//Create an XmlNodeReader to read the XmlDocument.

XmlDocument doc = new XmlDocument();

doc.Load(filename);

reader = new XmlNodeReader(doc);

//Parse the file and display each of the nodes.

while (reader.Read())

{

switch (reader.NodeType)

{

case XmlNodeType.Element:

Console.Write("", reader.Name);

break;

case XmlNodeType.Text:

Console.Write(reader.Value);

break;

case XmlNodeType.CDATA:

Console.Write(reader.Value);

break;

case XmlNodeType.ProcessingInstruction:

Console.Write("{0} {1}?>", reader.Name, reader.Value);

break;

case XmlNodeType.Comment:

Console.Write("", reader.Value);

break;

case XmlNodeType.XmlDeclaration:

Console.Write("<?xml version='1.0'?>");

break;

case XmlNodeType.Document:

break;

case XmlNodeType.EndElement:

Console.Write("{0}>", reader.Name);

break;

}

}

}

finally

{

if (reader!=null)

reader.Close();

}

}

} // End classImports System.IO

Imports System.Xml

Public Class Sample

Private Const filename As String = "items.xml"

Public Shared Sub Main()

Dim reader As XmlNodeReader = Nothing

Try

'Create an XmlNodeReader to read the XmlDocument.

Dim doc As New XmlDocument()

doc.Load(filename)

reader = New XmlNodeReader(doc)

'Parse the file and display each of the nodes.

While reader.Read()

Select Case reader.NodeType

Case XmlNodeType.Element

Console.Write("", reader.Name)

Case XmlNodeType.Text

Console.Write(reader.Value)

Case XmlNodeType.CDATA

Console.Write(reader.Value)

Case XmlNodeType.ProcessingInstruction

Console.Write("{0} {1}?>", reader.Name, reader.Value)

Case XmlNodeType.Comment

Console.Write("", reader.Value)

Case XmlNodeType.XmlDeclaration

Console.Write("<?xml version='1.0'?>")

Case XmlNodeType.Document

Case XmlNodeType.EndElement

Console.Write("{0}>", reader.Name)

End Select

End While

Finally

If Not (reader Is Nothing) Then

reader.Close()

End If

End Try

End Sub

End Class

该示例使用文件 items.xml 作为输入。The example uses the file, items.xml, as input.

]>

Test with an entity: &number;

test with a child element stuff

test with a CDATA section ]]> def

Test with a char entity: A

1234567890ABCD

注解

备注

在 .NET Framework 2.0 中,建议的做法是 XmlReader 使用 XmlReaderSettings 类和方法创建实例 Create 。In the .NET Framework 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. 这允许您充分利用 .NET Framework 中引入的所有新功能。This allows you to take full advantage of all the new features introduced in the .NET Framework. 有关详细信息,请参阅 "参考" 页中的 "备注" 部分 XmlReader 。For more information, see the Remarks section in the XmlReader reference page.

适用于

php xmlreader nodetype,XmlNodeReader.NodeType 属性 (System.Xml) | Microsoft Docs相关推荐

  1. php xmlreader nodetype,XmlReader.NodeType 属性 (System.Xml) | Microsoft Docs

    当在派生类中被重写时,获取当前节点的类型.When overridden in a derived class, gets the type of the current node. public: ...

  2. access里的多步oledb错误_(ADO) 的 ConnectionString 属性 - SQL Server | Microsoft Docs

    ConnectionString 属性 (ADO)ConnectionString Property (ADO) 01/19/2017 本文内容 指示用于建立与数据源的连接的信息.Indicates ...

  3. java rect offset_Rect.Offset 方法 (System.Windows) | Microsoft Docs

    傳回矩形,這個矩形是使用所指定水平和垂直數量從指定之矩形位移的矩形.Returns a rectangle that is offset from the specified rectangle by ...

  4. java graphics dispose_Graphics.Dispose 方法 (System.Drawing) | Microsoft Docs

    釋放這個 Graphics 所使用的所有資源.Releases all resources used by this Graphics. public: virtual void Dispose(); ...

  5. php xmlreader nodetype,C# XmlNodeReader.NodeType属性代码示例

    //引入命名空间 using System; using System.IO; using System.Xml; public class Sample { private const String ...

  6. 关于大XML文件与大节点处理(System.Xml.XmlTextReader)

    近期有个任务要求处理大XML文件,其中有个存了Base64的大节点(>90M,路径已知). 这种任务只能上XmlReader,即使如此大节点的处理还是头疼了一阵-- 最初查MSDN的时候,找到了 ...

  7. android transform xml xsl,XslCompiledTransform.Transform 方法 (System.Xml.Xsl) | Microsoft Docs

    使用 URI 指定的输入文档执行转换,然后将结果输出到 XmlWriter.Executes the transform using the input document specified by t ...

  8. XML序列之System.Xml.Serialization

    1,对象 public class School{public string Name { get; set; }public List<Classes> listClasses { ge ...

  9. arm linux下编译库System.Net.Primitives.dll和System.Xml.XmlSerializer.dll

    1.环境: /home/jello # uname -a Linux  3.10.0 #2 SMP Mon Mar 6 17:52:09 CST 2017 armv7l GNU/Linux 2.获取m ...

最新文章

  1. 01_MyBatis EHCache集成及所需jar包,ehcache.xml配置文件参数配置及mapper中的参数配置
  2. 面试题:彻底理解ThreadLocal 索引的利弊 背1
  3. 界面设计语言_使用任何语言设计界面的提示
  4. URAL 1106 Two Teams (DFS)
  5. Java IO流练习题-获取文本上每个字符出现的次数
  6. 先发不一定制人:美韩5G网络体验差遭吐槽
  7. 串口发送图片VGA显示
  8. K8S学习笔记之使用Fluent-bit将容器标准输入和输出的日志发送到Kafka
  9. 舆情监测软件TOOM
  10. 项目盈利模式分析报告
  11. 那些年你用过最好的键盘
  12. 我的系統中存在的问题
  13. Microsoft Word 教程「3」,如何在 Word 中创建项目符号列表、显示字数统计?
  14. Airflow调度 Design
  15. 读薄《高性能MySql》(三)索引优化
  16. java金蝶星空云金蝶Java 对接 金蝶云星空 接口 对接 金蝶API 对接 金蝶 接口 解决 会话失效 问题 会话已失效,请重新登录
  17. python音乐库_python - 网易云音乐的 Python 组件库
  18. 你告诉我,读书没有用
  19. python 多项式回归 假设检验_Python数据分析入门书籍推荐
  20. 转载:中国部分酱香型白酒名录

热门文章

  1. 基于时间序列的玩家行为模式分析
  2. 计算机体系结构基础引言
  3. easyExcel 填充模板生成新的excel
  4. 微软C# SQLHelper类
  5. 导出Excel之单元格插入图片
  6. ios微信小程序下拉刷新怎么配_[wx]微信小程序自定义下拉刷新
  7. down 网卡端口周期性的up_down 网卡端口周期性的up_端口每隔一段时间就就会不停up/down,是端口硬件故障了吗?......
  8. Python中求列表list的平均数
  9. Hadoop(三)HA
  10. 树梅派应用26:树莓派做FM发射器架设小型电台