|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
XML serializer question
hi,
I know i am supposed to put this question in XML section but since there are no posts there I am wondering if anybody here can help me. I am trying to use the xml_serializer and having some issues. I am using the following code: <?php // Set error reporting to ignore notices error_reporting(E_ALL ^ E_NOTICE); // Include XML_Serializer require_once '/usr/share/pear/XML_Serializer-0.18.0/Serializer.php'; require_once '/var/www/html/includes/dbconnect.php'; // Some data to transform $db = new dbconnect("xmlupload"); //$db->execQuery("SELECT * FROM products"); $result=$db->execQuery("SELECT * FROM products LIMIT 1"); while($row = mysql_fetch_array($result)) $array_final[]=array( 'SKU' => $row['SKU'], 'StandardProductID' => $row['ID'], 'LaunchDate' => '2007-10-12', 'ReleaseDate' => '2007-10-12', 'DescriptionData'=>array( 'Title' => $row['Name'], 'Description' => $row['ProductDescription'], 'MSRP' => $row['SaleAmount'], 'ItemType' => $row['ProductType']) ) ; } // An array of serializer options $options = array( "indent" => " ", "linebreak" => "n", "typeHints" => false, "addDecl" => true, "encoding" => "UTF-8", "tagName" => "rdf:RDF", "defaultTagName" => "Product" ); // Instantiate the serializer with the options $Serializer = &new XML_Serializer($options); // Serialize the data structure $status = $Serializer->serialize($array_final); // Check whether serialization worked if (PEAR::isError($status)) { die($status->getMessage()); } header('Content-type: text/xml'); echo $Serializer->getSerializedData(); ?> The result I am getting is: <?xml version="1.0" encoding="UTF-8"?> <array> <Product> <SKU>CRG</SKU> <StandardProductID>1</StandardProductID> <LaunchDate>2007-10-12</LaunchDate> <ReleaseDate>2007-10-12</ReleaseDate> <DescriptionData> <Title>Gun</Title> <Description><!--0032600--><BR>description</Description> <MSRP>12</MSRP> <ItemType>Tangible</ItemType> </DescriptionData> </Product> </array> My question is : how do I customize this to not display the "<array>" tag at the start of the file? thanks |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > XML serializer question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|