PHP jQuery Cookbook phần 4

Hãy xem xét một trường hợp mà người dùng được phép chọn một ngày trên một trang và một yêu cầu AJAX được thực hiện đến máy chủ để lấy một số dữ liệu chống lại ngày đó. Nếu yêu cầu là được chế biến và trong khi chờ đợi người sử dụng chọn một ngày khác | Simpo PDF Merge and Split Unregistered Version - http Working with XML Documents-------------------------------------------------------- 4. Run the file in your browser and you will be presented with the list of books. Clicking a book name will toggle the list of stories in that book with animation. How it works First we create an object objXML of the DOMDocument class. This class provides a number of properties and methods that can be used to manipulate an XML file. Names of nodes their values attributes and so on can be extracted from an XML file. Then we use the load method on the objXML. load method takes two parameters. First is the filename and the second parameter is libxml option constants. The second parameter is optional. We pass common. xml as the first parameter and LIBXML_NOBLANKS as the second one. We also pass LIBXML_NOBLANKS because we do not want any blank nodes to appear. Because we want to access all the book nodes we use the getElementsByTagName method and pass a book to it that returns a DOMNodeList object. A foreach loop has been used to iterate in this collection. There are several methods available to objects of the DOMNode class. We have used some of them here. The firstChild property gives us the immediate first child which is the book node in our case. nodeValue gives us the value inside the book tag which is the name of book. We wrap it in an h1 element. To access the attribute we use the attributes property. Attributes gives a map of all the attributes. We can navigate in this attribute collection using the item property. We retrieved the value of attribute at 0th position and that gives us the value of the year attribute. 90 Simpo PDF Merge and Split Unregistered Version - http ------------------------------------------------------------------------Chapter 3 Similarly to get the list of stories for a book we use getElementsByTagName again and then iterated in it for the value of each book .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.