Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Parsing XML using PHP4

By Burhan Khalid
2005-08-16


XML File Structure

eXtensible Markup Language or XML as its commonly called is primarily used to facilitate the interchage of information between environments that are not compatible natively (that is, they don’t support each other’s default file format). An example here would be a database server that doesn’t import Access files and has its own propriety data format.

The key word in XML is extensible. This means that the structure of the file is left entirely up to the creator. There are simply a few rules that you must follow to create XML (one such rule being that there can be only one root element). Other than that, the end user has free reign as to the tags that he may use, attributes, etc. One more thing about XML that we must understand is that there is no tag set for XML. Like HTML, which has a set of tags (<p>, etc.), XML has no pre-set tags. It is up to the end user to define tags for a file. In XML, a tag can be almost anything :

XML:
  1. <jim>info about jim</jim>
  2. <address type="home">555 Main Street</address>

A few more rules about XML and we will be on our way to our PHP code. XML documents must be well-formed. This means that there can be only one root element (the top most element), all child elements must be nested properly <p>foo<b>bar</b></p> not <p>foo<b>bar</p></b>, and all elements must have end tags.

In XML, an element is also referred to as a node.

Once these simple rules are understood, we can start creating a XML document that a XML parser will understand.



Tutorial Pages:
» Parsing XML using PHP4
» XML File Structure
» Creating our XML File
» Parsing with PHP
» Creating our Parser
» Setting up tag handlers
» Setting up content (data) handlers
» Starting up the parser
» Creating the gallery


© 2004-2005 Burhan Khalid


 | Bookmark
Related Tutorials:
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1
» Desktop Application Development with PHP-GTK

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources