<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[
Zend_Xml is a component that allow you to read nodes, create roots, append childs, set attributes, create texts in a XML resource, simply passing an XPath string or an array of strings with few or no parameters. Zend_Xml is a low level library for XML Document creation and manipulation.
Zend Framework: Zend_Xml Component Proposal
Proposed Component Name
Zend_Xml
Developer Notes
http://framework.zend.com/wiki/display/ZFDEV/Zend_Xml
Proposers
Daniele Orlando
Revision
0.1 - 1 August 2006: Initial Release (wiki revision: 9)
Table of Contents
1. Overview
For instance, recursive operation on different xml node can be done passing an array of xpath strings.
In the same way, passing an xpath string and an array of node name strings, we can add many childs in just one function call.
This is possible combining the simplicity of the XPath syntax with the DOM versatility.
Simply useful.2. References
3. Component Requirements, Constraints, and Acceptance Criteria
4. Dependencies on Other Framework Components
- Zend_Exception
5. Theory of Operation
Instantiate Zend_Xml with the root name(s) of the xml document and, if required, the external stylesheet.
Now, you are ready to build your XML document quickly and with total control on every operation.
6. Milestones / Tasks
- Milestone 1: [DONE] Base operations support
- Milestone 2: Full support for PHP DOM methods
- Milestone 3: Support for pre-existent DOMDocument and SimpleXML objects
- Milestone 4: Performance tuning
7. Class Index
- Zend_Xml - xml creation and manipulation class
- Zend_Xml_Exception - exception handler
8. Use Cases
| UC-01 |
|---|
Creation of a new XML document with an external stylesheet:
| UC-02 |
|---|
Basic editing:
| UC-03 |
|---|
Recursive operations:
9. Class Skeletons
The complete class is in "Attachments"
5 Comments
comments.show.hideApr 05, 2007
carlo amoroso
<p>it seems useful, keep working on it, i'll try the class. Anyone else is...? </p>
Jun 05, 2007
Bill Karwin
<p>What does this proposed class do that DOMDocument doesn't do already?</p>
<p>There is no need to reinvent functionality that already exists by another name in standard PHP.</p>
Jun 09, 2007
Daniele Orlando
<p>Hi, Bill!<br />
I think that DOMDocument is a powerful and complete component, too.<br />
But this is not a valid reason to consider Zend_Xml useless.<br />
Their scope is the same, but the way to achieve it is different.<br />
It's up to the developer to decide how to do it.<br />
So, I can answer that I'm not reinventing functionality, but I'm proposing a simpler and faster way to use them.</p>
<p>Why simpler and faster?</p>
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
<?php
/* Example 1 */
// DOMDocument way
$xml = new DOMDocument('1.0', 'UTF-8') ;
$xml->appendChild(new DOMProcessingInstruction('xml-stylesheet', 'type="text/xsl" encoding="UTF-8" href="http://www.domain.dom/xsl/stylesheet.xsl"' ) ;
$xml->appendChild(new DOMElement('Service')) ;
// Zend_Xml way
$xml = new Zend_Xml('Service', 'http://www.domain.dom/xsl/stylesheet.xsl', 'UTF-8', '1.0') ;
/* Example 2 */
// DOMDocument way
$xpath = new DOMXPath($xml) ;
$paths = array('//user[@level="high"]', '//admin') ;
foreach ($paths as $path) {
$nodelist = $xpath->query($path) ;
foreach ($nodelist as $node)
}
// Zend_Xml way
$xml->appendChild(array('//user[@level="high"]','//admin'), array('name'=>'nick'),array('active'=>'1')) ;
?>
]]></ac:plain-text-body></ac:macro>
<p>Zend_Xml is not a replacement for DOMDocument, but a wrapper that let the developer to program without the rewriting of repetitive code but just using arrayes and xpath strings.<br />
And wheter you have to use DOMDocument, simply use Zend_Xml->$Dom instance.<br />
Is there anything simpler and faster than this?</p>
<p>Thanks for your time.</p>
<p>p.s.:<br />
I'm using Zend_Xml in a production system and I think it very useful.</p>
Sep 12, 2007
Daniele Orlando
<p>Updated...<br />
Now supports namespaces.</p>
Aug 28, 2008
Dolf Schimmel (Freeaqingme)
<p>Nevermind, just noted: <a class="external-link" href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Xml+(Full+Fluent)+-+Daniele+Orlando">http://framework.zend.com/wiki/display/ZFPROP/Zend_Xml+(Full+Fluent)+-+Daniele+Orlando</a></p>