PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 10th, 2006, 09:10 PM
kaancho12 kaancho12 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 kaancho12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > XML serializer question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT