Thursday, 24 July 2008

Generating XML Documents Using PHP | Print |
 

The creation or saving of XML data stored in files on disk is the final topic for this chapter. Using the skills that you have already acquired in this chapter or by consulting other chapters in this book, you know how to process World Wide Web forms or query MySQL databases using PHP.

In most cases, the act of creating XML data from variable data that you have already acquired using PHP is as simple as taking one of two steps:

  • If your data is stored in a series of strings or other common objects, write out XML elements and data as needed to a disk file using standard PHP output functions, the same as you would when storing text data to any other type of file.

  • If your data is stored in a specialized object designed for XML manipulationsuch as a DomDocument (DOM extension) or SimpleXMLElement (SimpleXML extension) objectcall the extension's unique function or property for writing the object tree out to an XML file on disk.

Functions and Properties for Storing XML Objects as Files

If you have altered data stored in XML objects managed by PHP extensions, such as the DOM or SimpleXML extensions, and want to write these altered XML trees to text-based XML files, you'll need to use one of the functions or properties shown in Table 9.11 to perform the conversion or output.

Table 9.11. Functions and Properties for Saving XML Data

Function or Property

Extension

Notes on Usage

$object->asXML()

SimpleXML

Returns a well-formatted string containing the entire XML document stored in SimpleXMLElement $object; this can then be saved to a text file.

$object->save()

DOM

Writes the DOM XML tree contained in DomDocument $object out to a text file, whose name is given by a passed string.

$object->saveXML()

DOM

Returns a well-formatted string containing the entire XML document stored in DomDocument $object; this can then be saved to a text file.

$object->saveHTML()

DOM

Returns a well-formatted string containing the entire XML document stored in DomDocument $object using HTML-style formatting; this can then be saved to a text file.

$object->saveHTMLFile()

DOM

Writes the DOM XML tree contained in DomDocument $object out using HTML-style formatting to a text file, whose name is given by a passed string.

$object->dump_file()

DOM XML

Writes the DOM XML tree contained in DomDocument $object out to a text file, whose name is given by a passed string.

$object->dump_mem()

DOM XML

Returns a well-formatted string containing the entire XML document stored in DomDocument $object; this can then be saved to a text file.

This entry was posted on . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a comment.
Users' Comments (0)

Comment an article
  Name
  E-mail
   Title
Available characters: 600

No comment posted

Search
Read This
JavaScript - Events and Event Handling

Events and Event Handling We saw at the beginning of this section that one way to...
Read more....

Converting Movies To Psp Format.

Hey again, this is a real quick guide for anyone interested to get a movie onto there PSP without...
Read more....

Microsoft Expression Web(FrontPage 2007)

Expression Web is a professional design tool to create modern, standards-based sites which...
Read more....

Reward system - GABA

GABA, another neurotransmitter involved in the modulation of dopaminergic reward systems, plays a...
Read more....

Last Post
Live Traffic
Statistic


Excess Article
Last Comment

Home | Css Generator | Exchange Links | Computer | Ebook | English Section | Indo Section | Tips | Website | Sitemap
© 2007-2008 Online Science www.g-excess.com

Page Loading Time: 0.000015 seconds.