Re: Re: XML_Serializer - flexible node attributes?
| From: | Stephen Musgrave | Date: | Mon, 19 Dec 2005 20:43:09 +0000 |
| Subject: | Re: Re: XML_Serializer - flexible node attributes? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22314@lists.php.net to get a copy of this message | ||
Andrew -
Excellent! Thank you!
It didn't work at first but then I realized that the 'attributes' value for 'attributeArray' was actually the name of the array that was to be the attributes array. Click, got it.
Again, thanks for your help!
On Dec 19, 2005, at 12:29 PM, Andrew Nagy wrote:
Stephen, you need to specify the attributesArray option. Here is my option array: $options = array('indent' => ' ', 'addDecl' => true, 'mode' => 'simplexml', 'attributesArray' => 'attributes', 'rootName' => 'mets:mets', 'rootAttributes' => array('xmlns:mets' => 'http://www.loc.gov/METS/')); The options are listed as declared values in the serializer.php file if you want to get the full list. It doesn't seem to be documented in the pear manual Andrew Stephen Musgrave wrote:Andrew - Thanks for your help! But I am still having problems getting those values to get in as attributes. I am wondering if there is some other option I have to set? Thinking that the complexity of the code that I am writing for it was causing issues, I wrote up this simple XML code: include('../include/init.inc.php');-- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phprequire_once('XML/Serializer.php'); $serializer = new XML_Serializer();// create array to be serialized $xml = array ( "book" => array('attributesArray'=>array("ID"=>1),"title" => "Oliver Twist", "author" => "Charles Dickens"));$result = $serializer->serialize($xml); // check result code and display XML if success if($result === true) {header('Content-type: text/xml'); echo $serializer->getSerializedData();} The result is this: <array><book> <attributesArray> <ID>1</ID> </attributesArray> <title>Oliver Twist</title> <author>Charles Dickens</author></book> </array> Again, thanks for any assistance. On Dec 19, 2005, at 9:55 AM, Andrew Nagy wrote:Stephen Musgrave wrote:Here is an example what I am trying to accomplish: ... <ExchangeVisitor requestID="96" userID="userID" printForm="1">Using XML_Serializer, here is how you would accomplish this: $data = array('ExchangeVisitor' => array('attributesArray' => array('requestID' => 96, 'userID' => 'userID', 'printForm' => 1), 'lastName' => 'bbbb', 'firstName' => 'aaaa')); Hope this helps Andrew -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php<LastName>bbbb</LastName> <FirstName>aaaa</FirstName></ExchangeVisitor> ...