Easy processing of XML data in the. NET Framework (4-4)

Source: Internet
Author: User
?? Figure 9 String Array in Internet Explorer

?? The reader class has a special method for explaining BASE64 and BinHex encoded streams. The following code snippet demonstrates how to parse a document created with the BASE64 and BinHex encoding sets using the ReadBase64 method of the XmlTextReader class.

XmlTextReader reader = new XmlTextReader (filename);

while (reader. Read ()) {

if (reader. LocalName = = ' element ') {

byte[] bytes = new byte[1000];

int n = reader. ReadBase64 (bytes, 0, 1000);

String buf = Encoding.Unicode.GetString (bytes);

Console.WriteLine (BUF. Substring (0,n));

}

}

Reader. Close ();

?? The conversion from byte to string is accomplished by the GetString method of the Encoding class. Although I only allow the code based on the BASE64 encoding set, but can be abbreviated with the BinHex Exchange method name can be read based on BinHex encoded node content (using the ReadBinHex method). This technique can also be used to read any binary data that behaves in byte data, especially the image type.

The above is the easy processing of XML data (4-4) in the. NET framework, and more about topic.alibabacloud.com (www.php.cn)!

  • 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.