How to use getName in PHP
In this article I will explain how getName function used in PHP.
getName() Function
This function takes the name of an XML element tag from a Simple XML Element object.
Syntax
class SimpleXMLElement
{
string getName()
} |
Example
XML File
<?xml version="1.0" encoding="ISO-8859-1"?>
<note xmlns:b="https://dotnetheaven.com/articles/">
<book>iPhone</book>
<writer>wei sang lee</writer>
<name>Reminder</name>
<b:body>Don't forget me this weekend!</b:body>
</note> |
PHP Code
<html>
<body>
<?php
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 />";
}
?>
</html>
</body>
|
Output

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