Coder Profile - Show off your skills, get a coder profile.
 
 
 
[PHP] XML
Web Development
http://w3schools.com/xml/default.asp
http://www.php.net/manual/en/ref.xml.php

XML is not a replacement for HTML. It's a language specification to describe the information in HTML documents, whereas HTMLonly presents information. It's used in conjunction with Java to create small applications in mobile phones, and also to organize and transmit information (AJAX). The XML DOM is very similar to the HTML DOM in Javascript, but its structure is not based on how a web page should be formed, only information. Here is an example of a document:
Code :: 1.1 XML document Copy / Restore
  1. <?xml version="1.0" encoding="ISO-5589-1"?>
  2. <document>
  3.           <tag />
  4. </document>
It looks like a HTML document, but it has an odd DOC-TYPE and unrecognizable tags. Because of this, browsers cannot read it on its own. You have to design your own back-end in order to parse the XML. There are a couple of rules to designing a XML document, which you may be familiar with if you ever worked with XHTML.

All elements must be within a root element.

The root element would be the instance of the document, because it will be the first node you access. It can also be referred to as an entry-point, etc., but it can be anything you want.

All tags must be enclosed.

Just like XHTML, XML isn't very forgiving when it comes to tags. If you don't close nested tags or a single, empty tag, it will throw an error. That means if you've worked with just HTML thus far, you better get used to it.

Now that you know how to structure an XML document, you may be wondering about how it is read by the browser. There are several language specifications for XML that directly support it, but you can also use server-side languages like PHP, ASP, and Javascript's HTML DOM (client-side). To style the document, you can use CSS or XLST. Using CSS, you can just import the file.
Code :: stylesheet Copy / Restore
  1. <?xml-stylesheet type="text/css" href="style.css"?>
Remind you of anything? XLST, however, works with XPath. XPath uses regular expressions to search and match nodes and then styled using XLST functions. Since I have no actual experience with them, I won't explain them here. As for parsing the documents, you can read a short article I wrote about using the built-in DOM module here: http://www.coderprofile.com/coding-article/92/php-xml-html-dom-basics.

PHP.net also explains the built-in XML parser module and SimpleXML library. This all being in PHP. However, you may be wondering how you can use Javascript. You may not realize it, but you use the HTML DOM all the time when you are writing scripts (ie, document.write, document.getElementById(element)). I won't explain the OOP mechanics of the language here, you can look up C++ or Java if you want to know more about it. But these objects refer to the elements of the document in the DOM.

Using AJAX, you can load an XML document and then parse it.


Posted By remy
Please login to rate coding articles.

Click here to register a free account with us.
Comments
Please login to post comments.
 
Izzmo     Posted 135 Days Ago
 
 
Sure, this is alright. But you are missing the whole point of XML really, as a
in-between for transfers. XML is used as the middle-man.
 
urbn     Posted 205 Days Ago
 
 
I'm sorry, but you comment on how my article was rehashing, when clearly this is
the same.

Again, W3Shools has a far more understandable documentation on the basics of what
an XML document is, how to structure it, what the rules are and even the use of both
the Javascript and PHP DOMs.
Page 1 of 1
More Articles By This Author
[PHP] XML
[PHP] XML: HTML DOM Basics
Recently Posted "Web Development" Articles
Website Optimization
How to use Memcache on Windows
PHP Sessions = Member Database Cache
Speed Up Delivery of your JavaScript Libraries
A cool tool ^^
AJAX - When to use it?
Introduction To PHP
[PHP] XML
HTML vs XHTML
[PHP] XML: HTML DOM Basics
Recently Rated "Web Development" Articles
Website Optimization
How to use Memcache on Windows
Preventing raw PHP leaks on Apache
When to use OOP in PHP
AJAX - When to use it?
Speed Up Delivery of your JavaScript Libraries
[PHP] XML
A cool tool ^^
HTML vs XHTML
Introduction To PHP
source codes Categories articles
Browse All
Business & E-Commerce (1)
Databases (1)
Design & Creativity (1)
Internet & Web Sites (1)
Life In General (2)
Operating Systems (3)
Other (2)
Programming (48)
Security (10)
Software Development (5)
Web Development (15)
search Search Inside
Web Development
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved