iTechtalk


If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.



Reply
Old 10-10-2008, 12:39 PM   #1 (permalink)
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
Forum Jump


All times are GMT. The time now is 05:10 AM. itechtalk