XML Read and Write From Beginning | Web Programming Tutorial

XML Read and Write From Beginning

Published Date: October 18, 2013 |
Published Time: 12:27 am |

What is XML?

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human readable and machine readable. XML is designed to transport and store data.XML enables you to work with more data from more sources, and to get more from that data.

Hundreds of document formats using XML syntax have been developed,including RSS, Atom, SOAP, and XHTML.

it’s also a way to sharing , trasnsporting data with different platform.

Today we will see simply how to write xml file for storing various data and how can be read it  with php programming language.

Create XML File

Create a file name data.xml and write this code

Like HTML, XML uses elements and attributes, which are indicated in a document using tags. Tags begin with a < and close with a >. End tags include a / before the name of the element; empty tags include a / before the closing >

You can create xml file to share data for others Or you can use it for your own site.

Read XML file:

Now we will saw how simply we can read xml file with php.

create a php file named like xml_read.php and write this line of php code in php tag

Output :

konok is 26
Ronok is 18
Alamin is 25

So this is how we can retrieve data from xml file.

Later i will show, how to write xml file with php for dynamic data(may from database).And we will discuss about how to make RSS Feed and grab data from RSS Feed.

Leave a Reply

Your email address will not be published. Required fields are marked *