getName()We can get the name of the xml tag from a xml string or xml file using getname() function. We will use SimpleXMLElement object for this. Here is the sample string we will be using and we kept this sample xml string inside xml-sample1.php. We will load this string at the starting of the page.
Here is the PHP code using getName()
The output is
The get the name of all balance tags we will be using for loop and the child function. Here is the code.
Output is here
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