Exporting journal (XML file)

Are you an Editor, Author, or Journal Manager in need of help? Want to talk to us about workflow issues? This is your forum.

Moderators: jmacgreg, michael, vgabler, John

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 5
Joined: Thu Jan 22, 2004 2:27 am

Exporting journal (XML file)

Postby arnost » Tue Apr 12, 2005 12:21 pm

I wrote this script which can export journal and article metadata. It should export in same format which is accepted by xmlimport.php.

This is first testing version, have some bugs. (Did't check for undefined values, so sometimes produces empty tags like <address></address> instead of skipping this tag.)

Is somebody interested? Have any comments?

thanks for your reply

Arnost Valicek

Code: Select all


// Open Journal Systems 1.1
// (c) The Public Knowledge Project 2003
// http://www.pkp.ubc.ca
// This file is part of Open Journal Systems.
// Open Journal Systems is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// Open Journal Systems is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Open Journal Systems; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// admin/editor/xmlexport.php
// journal setup - table of contents and db creation


if(!validEditor()) {

function getFilenameForID($articleID) {
   $articlesql = "select * from tblfiles where nFileID='$articleID'";
   $articlesquery = $db->query($articlesql);
   $row = $db->assoc_array($articlesquery);

   return $row['chFileName'];

if ($db_connected) {

   header("Content-type: text/xml");
   header("Content-disposition: inline; filename=journal_export.xml");

   echo "<?xml version=\"1.0\" encoding=\""._tr('HTML_CHARSET')."\"?>\n";
   echo "<archive>\n";

   //get file path - contains HTML, PDF... files
   $fpq=$db->query("select  chFilePath from tbljournalconfig");
   $row = $db->assoc_array($fpq);
   $files_path = $row['chFilePath'];

   //list issues (only published!)
        $issues = $db->query("select * from tblissues where bPublished=1");
   $num_i = $db->num_rows($issues);
   for ($i=0; $i<$num_i; $i++) {
      $row = $db->assoc_array($issues, $i);

      echo "   <issue>\n";
         <title><?php echo $chIssueTitle ?></title>
         <volume><?php echo $nVolume ?></volume>
         <number><?php echo $nNumber ?></number>
         <year><?php echo $nYear ?></year>

      // for each published issue, do:
      if ($bPublished == '1') {
         //echo "****** $nIssueID - $chIssueTitle - $nVolume - $nNumber ******<br/>\n";

         $articles = $db->query("select *, DATE_FORMAT(dtDateSubmitted,'%Y/%m/%d') as dateSubmitted, DATE_FORMAT(dtDatePublished,'%Y/%m/%d') as datePublished   from tblarticles where fkIssueID=$nIssueID order by nOrder ");
         $num_a = $db->num_rows($articles);

         for ($j=0; $j<$num_a; $j++) {
            $row_a = $db->assoc_array($articles, $j);
            //echo "$nArticleID  - $chMetaTitle - $chMetaFormat - $chWorldID <br/>\n";

            #find section name
            $sections = $db->query("select *from tblsections where nSectionID=$fkSectionID");
            $sect_row =  $db->assoc_array($sections,0);
         <section><?php echo $sect_row['chTitle']?></section>
         <number><?php echo $nOrder ?></number>
         <title><?php echo $chMetaTitle ?></title>
         <abstract><?php echo $chMetaAbstract ?></abstract>

         <date_submitted><?php echo $dateSubmitted ?></date_submitted>
         <date_published><?php echo $datePublished ?></date_published>
            //echo getFilenameForID($fkFileHTMLID);
            $articlesql = "select * from tblfiles where nFileID='$fkFileHTMLID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];

            //echo $fkFilePDFID
            $articlesql = "select * from tblfiles where nFileID='$fkFilePDFID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];
            //echo $fkFilePostScriptID
            $articlesql = "select * from tblfiles where nFileID='$fkFilePostScriptID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];

         <language><?php echo $chMetaLanguage ?></language>
         <discipline><?php echo $chMetaDiscipline ?></discipline>
         <subject><?php echo $chMetaSubject ?></subject>
         <subject_class><?php echo $chMetaSubjectClass ?></subject_class>
         <coverage_geo><?php echo $chMetaCoverageGeo ?></coverage_geo>
         <coverage_chron><?php echo $chMetaCoverageChron ?></coverage_chron>
         <coverage_sample><?php echo $chMetaCoverageSample ?></coverage_sample>
         <!--<approach><?php echo $chXXX ?></approach>
         <sponsor><?php echo $chXXX ?></sponsor>-->
         //get authors of this article

         $authors = $db->query("select chFirstName,chSurname,chEmail from tblmetaauthors where fkArticleID=$nArticleID");
         $num_au = $db->num_rows($authors);
         for ($k=0; $k<$num_au; $k++) {
            $row_au = $db->assoc_array($authors , $k);


               if ($chFirstName!="") {
                  echo "<first_name>$chFirstName</first_name>";
               if ($chMiddleInitial !="") {
                  echo "<middle_initial>$chMiddleInitial</middle_initial";
               if ($chSurname!="") {
                  echo "<last_name>$chSurname</last_name>";
               if ($chEmail !="") {
                  echo "<email>$chEmail</email>";
               if ($chAffiliation!="") {
                  echo "<affiliation>$chAffiliation</affiliation>";
               if ($chPhone !="") {
                  echo "<phone>$chPhone</phone>";
               if ($chFax !="") {
                  echo "<fax>$chFax</fax>";
               if ($chMailAddr  !="") {
                  echo "<address>$chMailAddr</address>";
               if ($chBiography !="") {
                  echo "<biography>$chBiography</biography>";

      echo "   </issue>\n";

   echo "</archive>";


Posts: 352
Joined: Wed Dec 14, 2005 4:15 am

thanks to share !

Postby mbria » Thu Feb 23, 2006 4:16 am

Thanks to share arnost,

I will use your code as a base for a future issue of indexation that I need to fix.



Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Postby asmecher » Thu Feb 23, 2006 10:54 am

FYI, this code is applicable to OJS 1.x. For OJS 2.x, see the Journal Manager's "Import/Export Data" functions (which make use of the import/export plugins).

Alec Smecher
Open Journal Systems Team

Posts: 352
Joined: Wed Dec 14, 2005 4:15 am

Postby mbria » Fri Feb 24, 2006 3:41 am

thanks for the advice.

Return to “OJS Editorial Support and Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests