This section describes how to use XmlReader to read xml files.

Source: Internet
Author: User
In.. net development often needs to read and write xml files (app. config and web. config is a special column of the xml file used in WinForm and WebForm respectively, and Microsoft provides a general method, so we will not repeat it here ),. the. net class library provides a variety of methods for reading and writing xml files. Each method has its advantages and disadvantages, so it is practical. In.. net development often needs to read and write xml files (app. config and web. config is a special column of the xml file used in WinForm and WebForm respectively, and Microsoft provides a general method, so we will not repeat it here ),. the. net class library provides a variety of methods for reading and writing xml files. Each method has its advantages and disadvantages, so it is practical.

The following lists the classes for reading and writing xml files provided by the Microsoft. net class library and their features:

Class name

Advantages

Disadvantages

XmlReader

Fast, efficient, and scalable

Read-only, only forward, manual verification required

XmlDocument

Round-trip, read/write, and support for XPath filtering

Slower than XmlReader

XPathNavigator

Round-trip: supports XPath and XSLT

Read-only

XPathDocument

Better than XmlDocument, supports XPath and XSLT optimization

Slower than XmlReader

The XmlReader mentioned in this article is also a class in the Microsoft class library. it features fast, efficient, and scalable. Its disadvantage is read-only.

The following example describes how to use XmlReader:
(1) xml file used: meu. xml

 
   
      
       
       
       
       
       
       
     
    
      
       
       
     
    
      
       
       
  
 

(2) read and display: ReadXml. aspx

 
   
      
       
       
       
       
       
       
     
    
      
       
       
     
    
      
       
       
  
 (2) read and display: ReadXml. aspx <% @ Page Language = "C #" ContentType = "text/html" ResponseEncoding = "gb2312" %> <% @ Import Namespace = "System. xml "%>
 XMLReader instance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.