Re: Re: XML_Serializer - flexible node attributes?

From: Date: Mon, 19 Dec 2005 17:18:00 +0000
Subject: Re: Re: XML_Serializer - flexible node attributes?
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-22309@lists.php.net to get a copy of this message
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'); require_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">
    <LastName>bbbb</LastName>
    <FirstName>aaaa</FirstName>
</ExchangeVisitor> ...
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


« previous php.pear.general (#22309) next »