ASP. net2.0 XML series (6): Use xmlreadersettings to configure xmlreader output

Source: Internet
Author: User
Xmlreadersettings is an important class used to verify XML data. We will use this class to verify the XML file later. Here we will first demonstrate how to use xmlreadersettings to configure the attributes of the xmlreader output xmlreadersettings class.
Name Description
Checkcharacters Gets or sets a value indicating whether to perform a character check.
Closeinput Gets or sets a value that indicates whether the basic stream or textreader should be disabled when the reader is disabled.
Conformancelevel Gets or sets the level of consistency that xmlreader will follow.
Ignorecomments Gets or sets a value indicating whether to ignore comments.
Ignoreprocessinginstructions Gets or sets a value indicating whether to ignore the processing command.
Ignorewhitespace Gets or sets a value indicating whether to ignore insignificant white spaces.
Linenumberoffset Get or setXmlreaderThe row number offset of the object.
Linepositionoffset Get or setXmlreaderThe row position offset of the object.
Nametable Gets or sets the xmlnametable used for atomic string comparison.
Prohibitdtd Gets or sets a value indicating whether to disable document type definition (DTD) processing.
Schemas Gets or sets the xmlschemaset used for schema verification.
Validationflags Gets or sets a value indicating the schema verification settings. This setting is applied to verify the architectureXmlreaderObject (the validationtype attribute is setValidationtype. Schema).
Validationtype Gets or sets a value, which indicatesXmlreaderWhether to perform verification or type allocation during reading.
Xmlresolver Set xmlresolver for accessing external documents.

 

Instance:

Protected   Void Page_load ( Object Sender, eventargs E)
{
String Xmlfilepath = Request. physicalapplicationpath +   @" \ Employees. xml " ;
Xmlreadersettings settings = New Xmlreadersettings ();
Settings. ignorecomments = True ;
Settings. ignorecomments = True ;
Try
{
Using (Xmlreader Reader = Xmlreader. Create (xmlfilepath, settings ))
{
String Result;
While (Reader. Read ())
{
If (Reader. nodetype = Xmlnodetype. element)
{
Result =   "" ;
For ( Int Count =   0 ; Count < Reader. depth; count ++ )
{
Result+ = "---";
}
Result + =   " -> "   + Reader. Name +   " <Br/> " ;
This . Memployeeslabel. Text + = Result;
}
}
}
}
Catch (Exception ex)
{
This. Memployeeslabel. Text= "An exception occured:" +Ex. message;
}
}

 

-> employees
----> employee
-------> name
----------> firstname
----------> lastname
-------> city
-------> state
-------> zipcode
----> employee
-------> name
----------> firstname
----------> lastname
-------> city
-------> state
-------> zipcode
Related Article

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.