What is XML (Extensible Markup Language)?
Extensible Markup Language called as XML, is used to create a document or page which is easy to readable for human and machine. XML files are human readable. There is no special code present. XML is similar to HTML(HyperText Markup Language) but there are significant differences between them.
Extensible Markup Language or XML is "extensible" because the symbols, or tags, are unlimited, whereas in HTML, tags are predefined. In XML you can create your own tags which is not possible in html.
Example of XML tags are <location></location> and <fullname></fullname>. These tag indicate the information that is enclosed within that tag like location and full name of particular person.
XML was mainly designed to carry data, not to display data and XML tags are self descriptive.
XML parser is used to parse the XML file.
This tutorial of php code for beginners show you how to parse xml string using simple xml string parser.
<?php
$xml="<?xml version='1.0'?>
<newsarticle>
<topic name='Benzine'>
<from>Jennifer</from>
<heading>Actress List</heading>
<body>Details of all actress</body>
</topic>
</newsarticle>";
$xml = simplexml_load_string($xml);
foreach ($xml->topic as $record)
{
echo $record['name'], ' ';
echo $record->heading, ' ';
echo $record->body, '<br />';
}
?>
Hope this php tutorial is useful for you. Keep following www.phpcodeforbeginner.blogspot.in for more help.
No comments:
Post a Comment