All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
  Print view

Export XML
Author Message
PostPosted: Wed Dec 17, 2008 4:09 pm 
Offline

Joined: Wed Dec 17, 2008 3:57 pm
Posts: 3
Hi Everyone,
I am new to ATK framework and really excited with this. I got a problem like I need to generate an XML file from multiple tables from the DB.

I urgently require a solution. Can anyone help me.


Top
 Profile  
 

PostPosted: Thu Dec 18, 2008 3:13 am 
Regular
User avatar
Offline

Joined: Mon Feb 20, 2006 6:16 am
Posts: 389
Location: Germany
Hi,


http://www.navicat.com/ has an export wizzard with XML output.
But I m not sure wether this would need a custom querry first.
If you dont want to doit yourself you may could hire someone who writes a node-dependent XML export module. I dont know wether it already exists.

c u st.

_________________
Impresario, Web Developer since 1782, CTO of personal freedom ;-)


Top
 Profile  
 

PostPosted: Thu Dec 18, 2008 6:25 am 
Offline

Joined: Wed Dec 17, 2008 3:57 pm
Posts: 3
Hi stevie,
Actually I am building a website module with ATK Framework and on that I require to generate an XML automatically on a particular format.
Now problem is I am not getting any clue how to built an XML file and save it to a server path.

Regards,
Paul


Top
 Profile  
 

PostPosted: Thu Dec 18, 2008 8:03 am 
Pro
Offline

Joined: Mon May 23, 2005 7:11 am
Posts: 412
Location: Tysse, Samnanger, Norway
You could try something like this if you have your relations set up in the node:
Code:
header("Content-Type: text/xml");
//    The header line forces XML format to the browser
$res='<?xml version="1.0" encoding="UTF-8" ?>'.chr(13);
$arr=$this->selectDb(); //Get all records from all attributes
$res.="<records>".chr(13);
foreach ($arr as $key=>$line)
{
   $res.=make_sub_node($line,1,"record");
}
$res.="</records>".chr(13);
echo $res;
die();

function make_sub_node($arr,$level,$mainkey="")
  {
  $res.="<$mainkey>".chr(13);
  foreach ($arr as $key=>$line)
    {
    if (is_array($line) and count($line)>0)
      {
      $keys=array_keys($line);
      $key0=$keys[0];
      if ($key0=="0") //0 means onetomany relation
        {
        $res.="<$key".'s>'.chr(13);
        foreach ($line as $key2=>$line2)
          {
          $res.=make_sub_node($line2,$level+1,$key);
          }
        $res.="</$key".'s>'.chr(13);
        }
      else   //manytoone relation
        {
        $res.=make_sub_node($line,$level+1,$key);
        }
      }
    else
      {
      $res.="<$key>".chr(13);
      $res.="<text>".chr(13);
      $res.=htmlspecialchars($line);
      $res.=chr(13)."</text>".chr(13);
      $res.="</$key>".chr(13);
      }
    }
  $res.="</$mainkey>";
  return $res;
  }

_________________
Br
Olav B. Lygre


Top
 Profile  
 

PostPosted: Thu Dec 18, 2008 9:31 am 
Regular
User avatar
Offline

Joined: Mon Feb 20, 2006 6:16 am
Posts: 389
Location: Germany
wow nice!

_________________
Impresario, Web Developer since 1782, CTO of personal freedom ;-)


Top
 Profile  
 

Thanks oblygre
PostPosted: Thu Dec 18, 2008 2:26 pm 
Offline

Joined: Wed Dec 17, 2008 3:57 pm
Posts: 3
It solved my purpose...thanks again..


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group