Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0RC3

Request #2977 Add possibility to give XML encoding as parameter.
Submitted: 2004-12-16 12:41 UTC
From: tuupola Assigned:
Status: Suspended Package: XML_Tree
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 49 + 48 = ?

 
 [2004-12-16 12:41 UTC] tuupola
Description: ------------ Currently there is no way to tell XML_Tree which encoding it should use in XML declaration. Currently output is always something like <?xml version="1.0"?> By adding an optional parameter to constructor one should be able to produce something like: $xml = new XML_Tree('', '1.0', 'ISO-8859-1'); <?xml version="1.0" encoding="ISO-8859-1"?> Ability to choose the encoding is especially important when using XML_Tree with XML_Beautifier which defaults the encoding to UTF-8 if no encoding is provided. Reproduce code: --------------- <?php require_once('XML/Tree.php'); require_once('XML/Beautifier.php'); $xml = new XML_Tree(); $root = & $xml->addRoot('root'); $root->addChild('foo', 1); $str = $xml->get(); print $str; $fmt = new XML_Beautifier(); $str2 = $fmt->formatString($str); print $str2; ?> Expected result: ---------------- No expected result. Code and output is just provided to show how it currently works. Actual result: -------------- <?xml version="1.0"?> <root> <foo>1</foo> </root> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <root> <foo>1</foo> </root>

Comments

 [2004-12-16 17:46 UTC] aaron dot hawley at uvm dot edu
see related: http://pear.php.net/bugs/2968 The patch I've submitted makes XML_Tree options more general and uses XML_Util::getXMLDeclaration() to create the XML declaration. So one could specify the XML encoding with: $options = array('version' => array('1.0', 'ISO-8859-1', 'yes'); $xml = new XML_Tree('', '1.0', $options); In hindsight, the option name should probably not be "version", but "xml_declaration" or other.
 [2006-10-01 19:53 UTC] arnaud (Arnaud Limbourg)
Until the package gets a new maintainer.