How to use getName in PHP

In this article I will explain how getName function used in PHP.
  • 1833

getName() Function

This function takes the name of an XML element tag from a Simple XML Element object.


class SimpleXMLElement
string getName()


XML File

<?xml version="1.0" encoding="ISO-8859-1"?>
<note xmlns:b="">
<writer>wei sang lee</writer>
<b:body>Don't forget me this weekend!</b:body>

PHP Code

if (file_exists('test.xml'))
$xml = simplexml_load_file('D:\sachin\parse.xml');
echo $xml->getName() . "<br />";
foreach($xml->children() as $child)
echo $child->getName() . "<br />";



You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.