New xml.Node::withChild() method

at 2009-09-21 in Examples by friebe (0 comments)

To easily create XML documents, the xml.Node class has been extended with a new withChild() method complementing addChild(). In contrast to the latter, withChild() returns the node the child was added to instead of the added child.



To create the following XML fragment:

  <xsl:template match="/">  
<html>
<body>
<xsl:value-of select="/formresult/result"/>
</body>
</html>
</xsl:template>
...we can now use the following:
<?php 
$template= create(new Node('xsl:template', NULL, array('match' => '/')))
->withChild
(create(new Node('html'))
->withChild
(create(new Node('body'))
->withChild
(new Node('xsl:value-of', NULL, array('select' => '/formresult/result')))
)
)
;
?>



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES

Related

Find related articles by a search for «New».