What is XML? How to Access the Content Written in XML with PHP Language Code?
Prepared By Hitesh Vataliya
The Full form of XML is Extensible Markup Language
The XML is a widely accepted standard for data description and exchange.
It allows content authors to “mark up” their data with customized machine-readable tags.
These tags don’t come from a predefined list; instead, create their own tags and structure, suited to their own particular requirements, as a way to increase flexibility and usability.
Every XML document must begin with a declaration that states the version of XML being used.
The document prolog is followed by a nested series of elements.
Elements are the basic units of XML;
They typically consist of a pair of opening and closing tags that enclose some textual content.
The textual data enclosed within elements is known, in XML parlance, as character data. This character data can consist of strings, numbers, and special characters.
Some Rules angle brackets and ampersands
> Symbol > is used
< Symbol < is used
& Symbol & is used
XML is the latest standard language used to store and transfer the database among websites or we can say it is a standard language used in webservices.
Here in below Example, XML file given for accessing it's content (address.xml file) using php code :
address.xml
<?xml version='1.0'?>
<address>
<street>168, New Road</street>
<county>Baroda</county>
<city>
<name>Vadodara</name>
<zip>390021</zip>
</city>
<country>India</country>
</address>
PHP Code
<?php
// load XML file
$xml = simplexml_load_file('address.xml') or die ("Unable to load XML!");
// access XML data
echo "City: " . $xml->city->name . "\n";
echo "Postal code: " . $xml->city->zip . "\n";
?>
For coding class in gotri vadodara for students of msu, svit, kjit, kj polytechnic, nu, pu visit our official website : http://www.vataliyacomputer.in/python-coding-programming-class.php
ReplyDeletefor php project training in Vadodara, gujarat, india. visit : http://www.vataliyacomputer.in/php-coding-programming-class.php
ReplyDeleteThe course on XML and PHP at Vataliya Computer Classes provides a solid foundation, covering essential concepts and practical applications that are vital for web development. http://vataliyaclasses2.blogspot.com
ReplyDelete