TAILIEUCHUNG - Apress pro LINQ Language Integrated Query in C# 2008 phần 5

LINQ tới SQL hỗ trợ đầy đủ transactions, views, and stored procedures. Nó cũng cung cấp một phương pháp dễ dàng để tích hợp sự xác nhận dữ liệu và các quy tắc logic vào trong mô hình dữ liệu. | 218 CHAPTER 7 THE LINQ TO XML API Listing 7-34. Creating a Text Node and Passing It As the Value of a Created Element XText xName new XText Joe XElement xFirstName new XElement FirstName xName xFirstName This code produces the exact same output as the previous example and if we examine the internal state of the xFirstName object it too is identical to the one created in the previous example FirstName Joe FirstName Creating CData with XCData Creating an element with a CData value is also pretty simple. Listing 7-35 is an example. Listing 7-35. Creating an XCData Node and Passing It As the Value of a Created Element XElement xErrorMessage new XElement HTMLMessage new XCData H1 Invalid user id or password. H1 xErrorMessage This code produces the following output HTMLMessage CDATA H1 Invalid user id or password. H1 HTMLMessage As you can see the LINQ to XML API makes handling CData simple. XML Output Of course creating modifying and deleting XML data does no good if you cannot persist the changes. This section contains a few ways to output your XML. Saving with You can save your XML document using any of several methods. Here is a list of prototypes void string filename void TextWriter textWriter void XmlWriter writer void string filename SaveOptions options void TextWriter textWriter SaveOptions options Listing 7-36 is an example where I save the XML document to a file in my project s folder. CHAPTER 7 THE LINQ TO XML API 219 Listing 7-36. Saving a Document with Method XDocument xDocument new XDocument new XElement BookParticipants new XElement BookParticipant new XAttribute type Author new XAttribute experience first-time new XAttribute language English new XElement FirstName Joe new XElement LastName Rattz Notice that I called the Save method on an object of type XDocument.

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.