iTechtalk

Quick Search

Go Advanced

Member Login

Not registered? | Forgot Password
 
Register
Welcome
 
iTechtalk > Tutorials > Programming » Parsing and Transforming XML Documents
Reply
Old 10-10-2008, 11:39 AM   #1 (permalink)
 
dfsearch's Avatar
 
Junior Member
Join Date: Oct 2008
Posts: 2
Lightbulb Parsing and Transforming XML Documents

In the existent world, XML documents are extremely structured and precisely defined. A great deal of effort goes into scheming XML information products. One reason for the amount of effort that is essential is the extensible nature of XML. XML gives you a set of rules that allows you to generate these complex structured documents.

Those rules, however, provide for an almost infinite amount of possibilities for defining a document's structure. Keep that in mind when creating a PHP XML parsing application. Each application that you create will only work with one particular document structure. The extra endeavor spent designing the document structure pays off when you code applications that will parse that data.

Having assumed that, this next example tackles a couple of problems you will find in coding parsers for your own XML documents. These troubles include multiple instances of the same component (usually differentiated by attributes or content) and attributes: two things you are sure to find in "real" XML documents. The complexity of the example document, bebop.xml, is fairly basic, but as you will see, the complexity of coding a PHP parser to read more complex documents doesn't necessarily increase; it is really just doing a lot more of the same thing over and over. The basic function of the element and character handlers does not change. You just need to add additional cases to encompass the additional variations that your document requires.

This next example shows how a more complex document can be parsed and how to present the resulting data. The XML file is the beginning of series synopsis for the popular anime title, Cowboy Bebop. Although it is far from complete as far as the series information goes, the XML structure allows for adding data to make the document more comprehensive.

The output appears as in the following Figure:

dfsearch is offline   Reply With Quote
 
Reply

Bookmarks

Tags
documents, php, transforming, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replicating the documents between two file servers teqahead Windows server/NT/Work Station 1 04-15-2009 12:57 PM
How to recover the word documents? crazy4 Microsoft Office Support 1 03-30-2009 12:18 PM
Transforming source code to executable code in a Program dimension Programming 0 11-28-2008 09:29 AM
Using Drop Caps In Word Documents Logan Applications 0 11-10-2008 09:51 AM
Managing The Tables In Word Documents James Applications 0 11-10-2008 09:46 AM


 

Content Relevant URLs by vBSEO 3.3.0