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()