Pro PHP XML and Web Services phần 8

và chỉ ra rằng các nút trong phạm vi hiện tại không nằm trong một không gian tên mặc định. Ví dụ: Trong hình thức kinh điển, các nút yếu tố luôn luôn phải có một thẻ bắt đầu và kết thúc. Thẻ trống là không Mẹo được cho phép. Bạn phải do những người sử dụng SOAP như nó là bởi vì SOAP | 642 CHAPTER 17 REPRESENTATIONAL STATE TRANSFER REST Load the XML document from file system and make sure IDs are properly handled function getResource doc new DOMDocument The following call uses the optional options parameter available only in PHP and higher if doc- load GLOBALS resource_filename LIBXML_DTDATTR return doc return NULL Add a new p element using ID id with the contents value. If id already exists in document do not add new content function addResource id value if doc getResource if element doc- getElementById id NULL element doc- documentElement- appendChild doc- createElement p value element- setAttribute ID id if doc- save GLOBALS resource_filename return doc- saveXML return get_error Update or delete an existing p element based on id. If id does not exist in document return generic error function updateResource id value isdel FALSE if doc getResource if element doc- getElementById id if isdel element- parentNode- removeChild element else while element- firstChild element- removeChild element- firstChild element- appendChild doc- createTextNode value if doc- save GLOBALS resource_filename return doc- saveXML return get_error CHAPTER 17 REPRESENTATIONAL STATE TRANSFER REST 643 action Set content type for XML header Content-type text xml Determine action based on POST or GET if isset _POST isset _POST action _POST action action _POST action else if isset _GET isset _GET action _GET action action Perform specified action as long as needed parameters have been passed if action isset _POST id isset _POST value echo addResource int _POST id _POST value else if action isset _POST id echo updateResource int _POST id NULL TRUE else if action isset _POST id isset _POST value echo updateResource int _POST id _POST value else if action The raw XML document could just be returned but here we ensure it is proper XML before sending. If it is not proper it will not load into the DOMDocument if .

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.