Skip to end of metadata
Go to start of metadata
Zend_Xml - Vadim Gabriel

Zend Framework: Zend_Xml Component Proposal

Proposed Component Name Zend_Xml
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Xml
Proposers Vadim Gabriel
Zend Liaison TBD
Revision 1.0 - 1 January 2008: Initial Draft. (wiki revision: 8)

Table of Contents

1. Overview

Zend_Xml_Parser - Is a component that will easily allow parsing an XML document into a multidimensional php array.
Zend_Xml_Writer - Is a component that will easily allow parsing a multidimensional array into a well formatted xml document.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will allow parsing a simple/associative/multidimensional array into a well formatted xml document.
  • This component will allow parsing an xml document into a simple/associative/multidimensional php array.
  • This component will allow printing the XML document to the user browser.
  • This component will allow downloading the formatted XML document as an attachment.
  • This component will allow iterating over the parsed array directly.

4. Dependencies on Other Framework Components

  • Zend_Exception

5. Theory of Operation

Parser - Simply pass a string representing an xml document as the first parameter of the constructor function or a file name as the second parameter to parse it into an array and access the contents immediately.
Writer - Simple pass an array to the class constructor and either display or download the formatted xml document by using the same method with different parameters passed respectively.

6. Milestones / Tasks

  • Milestone 1: [DONE] Create the proposal
  • Milestone 2: [DONE] Initial class design
  • Milestone 3: Submit the proposal for community review
  • Milestone 4: Create working prototype
  • Milestone 5: Create code-covering unit tests.

7. Class Index

  • Zend_Xml_Exception
  • Zend_Xml_Parser
  • Zend_Xml_Writer

8. Use Cases

UC-01: Basic Xml Document Parsing (string)

Parsing an xml document by passing a string to the class constructor

UC-02: Basic Xml Document Parsing (file)

Parsing an xml document by passing a file name to the class constructor

UC-02: Basic Xml Document Writing

Parsing an array into a formatted XML document

UC-02: Basic Xml Document Writing

Parsing an array into a formatted XML document & downloading it as an attachment

9. Class Skeletons

Zend_Xml_Parser

Class Skeleton

Zend_Xml_Writer

Class Skeleton

Labels:
xml xml Delete
parser parser Delete
writer writer Delete
array array Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Apr 24, 2009

    Can you explain the advantages of this component over built-in PHP functionality in XMLReader/SimpleXML and XMLWriter?

    1. Apr 24, 2009

      Hey,

      Probably the same as any other Zend component, Ease of use.

      But i saw that most of this can be achieved using Zend_Config components, Although it lacks a few features.

      Vince.

  2. Jul 05, 2010

    in_array($name, array_keys($children)) can be replaced with array_key_exists($name, $children)

  3. Nov 04, 2010

    I look forward to this component and see it as oddly missing in ZF up to this point. Sure there are built in PHP functions for XML, but there are also native PHP functions for Json, Database interaction, Sessions, etc, etc, all of which have ZF components that abstract and simplify their use. The native PHP functions can be cumbersome to use, plain and simple. That's part of the reason frameworks exist.

    I would suggest a generic Zend_Xml component similar to Zend_Json, that in turn uses your Zend_Xml_Parser and Writer. This class could accept a string of XML to it's constructor and then immediately parse and provide an interface for accessing the data...without the vagaries and complexities of PHP's DOMElement's (which unfortunatly seem to crop up here and there in ZF – ahem, Zend_Dom...which could utilize this component rather than relying on DOMElement).

    I agree that Zend_Config does most of this (you can access the XML as an object, which is great)...but it is not a dedicated XML component. Perhaps Zend_Config_Xml should be converted to use Zend_Xml internally for parsing/writing XML (once this is complete of course).

  4. Feb 06, 2011

    Archiving this proposal, feel free to recover it when you want to work on it again. For more details see this email.