Một thẻ đã tồn tại với tên chi nhánh được cung cấp. Nhiều lệnh Git chấp nhận cả tên thẻ và tên nhánh, vì vậy việc tạo nhánh này có thể gây ra hành vi không mong muốn. Bạn có chắc chắn muốn tạo nhánh này không?
Tạo một tài liệu XML từ biểu diễn DOM. Hàm này thường được gọi sau khi xây dựng tài liệu dom mới từ đầu như trong ví dụ bên dưới
Thông số
nút
Sử dụng tham số này để chỉ xuất một nút cụ thể mà không cần khai báo XML thay vì toàn bộ tài liệu
Tạo một tài liệu XML từ biểu diễn DOM. Hàm này thường được gọi sau khi xây dựng tài liệu dom mới từ đầu như trong ví dụ bên dưới
参数
node
Sử dụng tham số này để chỉ xuất một nút cụ thể mà không cần khai báo XML thay vì toàn bộ tài liệu
XML là ngôn ngữ đánh dấu để chia sẻ dữ liệu trên web, XML dành cho cả người có thể đọc được và máy có thể đọc được. Lớp SimpleXMLElement đại diện cho một tài liệu XML trong PHP
SimpleXMLElement. hàm saveXML[] tạo thành một chuỗi XML của đối tượng SimpleXMLEuity hiện tại và trả về nó. Nếu bạn chuyển một giá trị chuỗi biểu thị tên tệp dưới dạng tham số thì hàm này sẽ lưu chuỗi XML trong tệp đã chỉ định
cú pháp
SimpleXMLElement::saveXML[[$file_name]];
Thông số
Sr. NoThông số & Mô tả1tên_tệp [Tùy chọn]
Đây là một giá trị chuỗi đại diện cho tên tệp mà bạn cần lưu trữ chuỗi XML đã tạo ở trên cùng
Giá trị trả về
Hàm này trả về một chuỗi đại diện cho chuỗi XML trong trường hợp thành công và giá trị boolean FALSE trong trường hợp thất bại
Nếu bạn đã chuyển tên tệp tùy chọn làm tham số thì hàm này trả về TRUE nếu thành công và FALSE khi thất bại
Phiên bản PHP
Chức năng này lần đầu tiên được giới thiệu trong PHP Phiên bản 5 và hoạt động trong tất cả các phiên bản sau
Ví dụ
Ví dụ sau minh họa việc sử dụng SimpleXMLIterator. hàm saveXML[]
JavaFX 535 Krishna 11 "; $xml = new SimpleXMLElement[$str]; $xml_string = $xml->saveXML[]; print[$xml_string]; ?>
Điều này sẽ tạo ra kết quả sau -
JavaFX 535 Krishna 11
Ví dụ
Sau đây là một ví dụ về chức năng này với tên tệp tham số tùy chọn -
JavaFX 535 Krishna 11 "; $xml = new SimpleXMLElement[$str]; //Adding the child node $xml->addChild['Price', '600']; $xml->saveXML["output.xml"]; ?>
Nếu bạn xác minh nội dung của đầu ra tệp đầu ra. xml, bạn có thể quan sát phần tử XML được thêm vào như hình dưới đây -
formatOutput = true; $root = $doc->createElement['book']; $root = $doc->appendChild[$root]; $title = $doc->createElement['title']; $title = $root->appendChild[$title]; $text = $doc->createTextNode['This is the title']; $text = $title->appendChild[$text]; echo "Saving all the document:\n"; echo $doc->saveXML[] . "\n"; echo "Saving only the title part:\n"; echo $doc->saveXML[$title]; ?>
Tài liệu DOM. Hàm saveXML[] là một hàm có sẵn trong PHP được sử dụng để tạo một tài liệu XML từ biểu diễn DOM. Chức năng này được sử dụng sau khi xây dựng tài liệu dom mới từ đầu
Comment to `devin at SPAMISBAD dot tritarget dot com''s post:
Thanks for pointing out the pitfalls of `formatOutput' vs. `load*[]'. This has certainly saved me from some possible surprises.
________số 8_______
As you point out, `preserveWhiteSpace' must be set before loading the DOM from the source string [I'm working with `loadXML[]' but I believe the situation should be the same with `load[]' you used]. This looks logical, as this property seems to control the parsing and DOM creation process during which text nodes containing the whitespace are either included or dropped. This can be proven by dumping the DOM structure and comparing the results based on the value of `preserveWhiteSpace'. With `preserveWhiteSpace' set to `FALSE', no text nodes containing whitespace will be present in the returned DOM. When this property is `TRUE', these nodes will be present.
Note: When speaking about the whitespace in the previous paragraph, we're most certainly speaking about so called `whitespace in element content' or `element content whitespace', if I'm not mistaken. See also my comment in the notes of `DOMText->isWhitespaceInElementContent[]' method.
As for the mysterious effect on the output of `saveXLM[]', I think the explanation lies in the presence or absence of the above mentioned whitespace text nodes. This was also proven by experiments: After adding such a node into a DOM which contained none [the DOM was created using `loadXML[]' with `preserveWhiteSpace' set to `FALSE'], the output formatting got affected in a such a way, the formatting got lost for the rest of the document after the added node. I think the presence of whitespace text nodes forces such rendering, that the content of these nodes is used to separate adjoining nodes thus disabling default formatting. Only when there are no such text nodes present, the ouput formatting takes effect [provided the `formatOutput' is set to `TRUE', of course].
Well, the thing I don't really understand is how you did get an output of a signle line with `formatOutput' set to `TRUE'. This has happened to me when no whitespace text nodes were present [ie. when loading the XML with `preserveWhiteSpace' set to `FALSE'] *and* with `formatOutput' set to *`FALSE'* [with the opposite value of `formatOutput', the formatting should do it's work and you should not end up with just one line]. But I haven't seen your source. Perhaps you had whitespace nodes containing no new-lines in your DOM?
As for the CAUTION about root element, I didn't see any problems with empty root element neither in shortened nor full form. What did you have in mind, when you said it `WORKS' or `DOES NOT WORK'?