Skip to main content
January 23, 2009
Question

Multiple XML data sets

  • January 23, 2009
  • 8 replies
  • 531 views
Hi

I want to create multiple XML datasets on one page. For example: 2 queries (php,mysql), 2 results. Then on the page where you define the datasets you normally add this:

<script type="text/javascript">
<!--
var dsEmployees = new Spry.Data.XMLDataSet("export.php", "company/employee");
//-->
</script>
Now, this works perfectly, but how can i add multiple datasets, for example:

<script type="text/javascript">
<!--
var dsEmployees = new Spry.Data.XMLDataSet("export.php", "company/employee");
var dsEmployees2 = new Spry.Data.XMLDataSet("export.php", "company2/employee2");
//-->

Once i add the second dataset, only the first one displays. Anybody have any ideas?

Thanks
</script>
This topic has been closed for replies.

8 replies

January 23, 2009
But thats my whole problem, it doesn't even get that far, even if i add the html, repeats, regions etc.. it only shows the first table. Also if i open the source file (whith the php queries) it also only shows the first table, but nothing more than that.
_V11
Participating Frequently
January 23, 2009
I was talking about the html of the page, containing the regions.. repeats or anything that doesn't show up... and the rendered xml, not the php query :D
January 23, 2009
Ok, here is the code that gets the data and exports it to XML:
Query 1:
=============================
mysql_select_db($database_conn_export, $conn_export);
$query_rsEmployees = "SELECT * FROM employees_emp";
$rsEmployees = mysql_query($query_rsEmployees, $conn_export) or die(mysql_error());
$row_rsEmployees = mysql_fetch_assoc($rsEmployees);
$totalRows_rsEmployees = mysql_num_rows($rsEmployees);

// Begin XMLExport rsEmployees
$xmlExportObj = new XMLExport();
$xmlExportObj->setRecordset($rsEmployees);
$xmlExportObj->addColumn("firstname_emp", "firstname");
$xmlExportObj->addColumn("lastname_emp", "lastname");
$xmlExportObj->addColumn("address_emp", "address");
$xmlExportObj->addColumn("salary_emp", "salary");
$xmlExportObj->setMaxRecords("ALL");
$xmlExportObj->setDBEncoding("ISO-8859-1");
$xmlExportObj->setXMLEncoding("ISO-8859-1");
$xmlExportObj->setXMLFormat("NODES");
$xmlExportObj->setRootNode("company");
$xmlExportObj->setRowNode("employee");
$xmlExportObj->Execute();
// End XMLExport rsEmployees
=============================
Query 2:
=============================

=============================
mysql_select_db($database_data_one, $data_one);
$query_mem_details = "SELECT * FROM wherever where mem='$mem_number'";
$mem_details = mysql_query($query_mem_details, $data_one) or die(mysql_error());
$row_mem_details = mysql_fetch_assoc($mem_details);
$totalRows_mem_details = mysql_num_rows($mem_details);

// Begin XMLExport Member Details
$xmlExportObj = new XMLExport();
$xmlExportObj->setRecordset($mem_details);
$xmlExportObj->addColumn("firstname", "firstname");
$xmlExportObj->addColumn("lastname", "lastname");
$xmlExportObj->setMaxRecords("ALL");
$xmlExportObj->setDBEncoding("ISO-8859-1");
$xmlExportObj->setXMLEncoding("ISO-8859-1");
$xmlExportObj->setXMLFormat("NODES");
$xmlExportObj->setRootNode("Member");
$xmlExportObj->setRowNode("Details");
$xmlExportObj->Execute();
// End XMLExport Member Details
=============================

And here is the page that calls these two datasets:

<script type="text/javascript">
<!--
var dsEmployees = new Spry.Data.XMLDataSet("export.php", "company/employee");
var mem_details = new Spry.Data.XMLDataSet("export.php", "Member/Details");
//-->

And only the first one appears.
</script>
_V11
Participating Frequently
January 23, 2009
Uhm i guess so. :)

can you also post a sample xml? also, are you using the latest version of Spry ? (1.6.1)
January 23, 2009
No, but i can post the code?
_V11
Participating Frequently
January 23, 2009
Do you have a online url?
January 23, 2009
Yes, i created 2 connections (php,mysql) on the one page, exported the data to 2 seperate tables, but when i try and call both tables on the page where the datasets are defined (see my original post), only 1 appear. Even in DW CS4, when i want to add another spry dataset (XML) using the wizard, only the first one comes up, it doesn't even show 2 data sets.
_V11
Participating Frequently
January 23, 2009
did you add the other dataset to the regions?