: 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.