Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Đây là một trong những tính năng quan trọng mà các nhà phát triển đang kêu gọi cho các phiên bản trước của Visual Studio.các thẻ HTML có chứa các thẻ nơi con trỏ chuột của bạn hiện tại đang nằm. Nhấp chuột vào bất kỳ các nút cho phép các nhà phát triển có thể tùy chọn thay đổi lựa chọn cấp nguồn, | Chapter 4 script html xmlns http www.w3.org 1999 xhtml head runat server title Writing XML File title head body form id form1 runat server div asp label id lblResult runat server div form body html Listing 4-8 uses urn employees-wrox as the namespace and the namespace prefix used is emp . If you navigate to the code Listing 4-8 in a browser you will see the output shown in Figure 4-6. Figure 4-6 In Listing 4-8 you supplied the namespace as an argument to the WriteStartElement as shown in the following code. writer.WriteStartElement employee urn employees-wrox You can also accomplish this effect using the following two lines of code as well. string prefix writer.LookupPrefix urn employees-wrox writer.WriteStartElement prefix employee null 94 Reading and Writing XML Data Using XmlReader and XmlWriter By leveraging the LookupPrefix method you can get reference to the namespace space prefix in a local variable and then supply it as an argument to methods such as WriteStartElement . The advantage to this approach is that you don t have to supply the namespace to each of the creation methods you simply supply the prefix obtained through the LookupPrefix method to the creation methods. Writing Images Using XmlWriter The techniques described in the previous sections can also be used with any sort of binary data that can be expressed with an array of bytes including images. This section provides you with an example and demonstrates how to embed a JPEG image in an XML document. The structure of the sample XML document is extremely simple. It consists of a single employee node and inside that node there is an image node holding the binary image data plus an attribute containing the original file name. Code required for implementing this is shown in Listing 4-9. Listing 4-9 Embedding an Image in an XML Document @ Page Language C @ Import Namespace System.Xml @ Import Namespace System.IO script runat server void Page_Load object sender EventArgs e string xmlFilePath @ C Data .