XML & PHP

Noor ul Huda

This tutorial is all about XML parsing using PHP DOM parser. This tutorial 'll help you in learning of XML creation using php. First you have to know about XML, why it is used and where it is used? If you are newbie in development field.
  
What is XML?

The XML is very simple language that allows the developers to store the structured data into XML files. There are various uses of the XML files.


Why XML used?

XML used for following purposes:
  1. For developing the database driven applications.
  2. On the web web services such as PayPal service etc. are using the XML language
  3. We developers can used the XML data files to generate the dynamic content by applying different Style sheets.
  4. XML is also used to develop the content management systems
  5. Database development with the XML is another good use of XML. You program can use the XML data file for business processing.
  6. Many software development frameworks is using XML files to store the configuration data for the application. For example JPA uses persistence.xml file for configuring the JPA environment.
  7. Many companies are using XML for electronic data exchanges
  8. XML is used to transport and the data on internet and between different programs
  9. XML is also used very easily where using database and flat files are difficult.
  10. XML is also used to create other languages MathXml, SVG etc.
  11. In XML there is total separation of XML data and style sheet.
  12. Many databases are providing the support for XML database

Why XML is so important in programming? 

These days programming of almost all the technologies is using XML file to store the data or transport the data over the internet. With the help of XML you can send the data from your Java program to a .NET application and vice versa. XML is supported by PHP, Java, ASP, .NET, C, C++, Perl, Python and almost all the programming languages. XML parser API is used by the programmers to parse the data stored in XML file. XML parsers are available for all the programming languages, which makes the use of XML file very easy.

I think its enough for beginner to know about XML purpose. If you are interesting in learning XML in depth, then dig it and google it... :)

Now comes to XML parsing using PHP.

First you have to dump database file. Download  zip file from here link.

Create PHP Project

First you have to create PHP project in htdocs folder of server . I used WAMP server for this application.

I create new folder with name "PHP_XML" in htdocs folder of server.
then i create index.php with UI interface. There is drop down which show table names of database.
There is snapshot of index page.


There are names of tables in drop down which are in sampledb Database. Drop down shows tables names like this:



Select a table name and press Generate XML button, then there is xml file of that table created in upload folder and screen show message after successful parsing.




In upload folder, you can check XML file of that table, like i create products table xml file and i found it in upload folder.

  
 You can Download source code of project from here. XML Parsing

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !