Inserting child element and data by addChild functionBy using simpleXMLElement we can add child element to XML data structure. Here is an example. We have used our sample XML file for this.xml-sample1.php
In above code we have added one child element Job at root level and now let us try to add child element at lower node. Here is the code.
The output is here
Example using xml-sample2.xml
Ouptut is here
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
|