asXML string output, writing to file , xml string to fileWe have seen how we can create a SimpleXMLElement object. Now we will translate the XML data to a string by using asXML function. Here is the sample code. We have already used our XML data sample file for this.
To write the same string to a file we will change the above code like this.
Above line will create the file test.php and on successful will return 1
This article is written by plus2net.com team.
PHP & XML getName(): Name of the XML element or tag children(): Children of a XML node count(): Counting number of Children of an XML element simplexml_load_file(): creating object by reading from XML file simplexml_load_string(): creating object by using XML formatted string asXML: Getting string output or writing to file addAttribute(): Adding attribute to element of XML object addChild(): Adding Child element to element of XML object getNamespaces(): Getting NameSpaces from XML object XML from Database(): Generating XML from table records