TAILIEUCHUNG - Use XMLWriter to Create an XML Document

Sử dụng XMLWriter để tạo một tài liệu XML Đôi khi tôi cần phải dùng dữ liệu đó là trong cơ sở dữ liệu của tôi và viết nó ra một tài liệu XML. Tôi nghe nói rằng XMLWriter là một cách tốt để làm điều này. XMLWriter làm gì, và làm thế nào để tôi tạo một tài liệu XML với nó? | Use XMLWriter to Create an XML Document Sometimes I need to take data that is in my database and write it out to an XML document. I heard that XMLWriter is a good way to do this. What does XMLWriter do and how do I create an XML document with it Technique The XMLWriter provides a quick way to generate streams or files that contain XML data. The stream is not cached it is forward-only. The XML data that the XMLWriter generates conforms to W3C XML and the namespaces in XML recommendations. With XMLWriter you can accomplish the following Create well-formed XML. Manage the output-including methods to determine the progress of the output-with the WriteState property. Flush or close the output. Write multiple documents to one output stream. Encode binary bytes as base64 and as binhex and write out the resulting text. Report the current namespace prefix xml lang or xml space scope. Write valid names qualified names and name tokens. XMLWriter has one implementation the XMLTextWriter. To show you how to use the XMLTextWriter the sample code will create a data table allowing the user to add names to it. Then the XMLTextWriter will be used to write the data from the data table into an XML document. Creating the Data Table Rather than using a DataAdapter object to create and populate the data table from live data the code will create the data table from scratch and the user will add data to it. To perform this task add the properties and methods shown in Table . The first object that will be created and utilized is the DataColumn object. Table . Objects Properties and Methods for Creating a DataTable Object Object Property Method Description DataColumn ColumnName Specifies the Column name for the current data column that is being created. DataColumn Caption Stores the Caption used to be displayed. Add Adds the current DataColumn object to the collection of columns in the data table. DataTable NewRow Creates a DataRow object. DataRow Item .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.