Create an XML file

Source: Internet
Author: User
: This article describes how to create an XML file. if you are interested in the PHP Tutorial, refer to it. Use dom to create an xml file

 CreateTextNode ('like or like'); // 2 create a name node $ name = $ dom-> createElement ('name '); // 3 Add the name node $ name-> appendChild ($ comic) in the text; // 4 create CDATA, prepare to put 5 $ cdata = $ dom-> createCDATASection ('this is cdata, this film is bl to 233 '); // 5 creates an intro node, with 2 $ intro =dom dom-> createElement ('Intro '); // 6 put cdata into intro $ intro-> appendChild ($ cdata); // 7 create a goods node $ goods = $ dom-> createElement ('Goods '); // put all nameintro into goods $ goods-> appendChild ($ name); $ goods-> appendChild ($ intro ); // 8 create goodsid attributes $ id = $ dom-> createAttribute ('goods _ id'); $ id-> value = 'g01 '; // 9 put properties-"goods node $ goods-> appendChild ($ id); // 10 $ store = $ dom-> createElement ('store '); $ store-> appendChild ($ goods); $ dom-> appendChild ($ store); // directly output header ('content-type: text/XML '); echo $ dom-> savexml (); // save // $ dom-> save ('Try. XML ');

The direct output is on the webpage.

You can easily create a class or use simplexml

The above describes how to create an XML file, including some content, and hope to help those who are interested in the PHP Tutorial.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.