Corda Server™ can parse through an HTML document or Web page, and load data contained within any HTML table. If you already have data stored in tables within Web pages, simply tell Corda Server the location of the Web page and the title of the table (or number of the table, in order of occurrence within in the page's HTML code). This process is sometimes referred to as screen-scraping.
This section is divided into the following topics:
Make sure to organize HTML table data in a manner consistent with the spreadsheet format used by Corda Builder's Data Editor. For more information about organizing data, see Graph Data and About Maps in the Corda Builder™ User Guide.
For non-standard graph types (X-Y and Time Plots), see Data Organization in the Corda 7 Graph Guide.
The example below shows a basic HTML data table:
Example Data in HTML Table Format (Graphs)
<table title="Spreadsheet">
<tr>
<td> </td>
<td>Arrivals</td>
<td>Departures</td>
<td>Unused</td>
<td>Out of Commission</td>
</tr>
<tr>
<td>Atlanta</td>
<td>23</td>
<td>36</td>
<td>11</td>
<td>7</td>
</tr>
<tr>
<td>Boston</td>
<td>41</td>
<td>17</td>
<td>25</td>
<td>9</td>
</tr>
</table>
Note: HTML tables can contain an optional first row with header information, which can be ignored. Rows that have no data values are always ignored. The only exception to this is the first row, which can either be ignored or used for category names.
If a graph uses data categories, the file can also be organized as shown in the example below, where each row of data represents a single data value. For more information, see Alternative Data Organization Format in the Corda 7 Graph Guide.
Example Data in Alternative HTML Table Format (Graphs)
<table border="1" title="CordaData">
<tr>
<th>Atlanta</th>
<td>Arrivals</td>
<td valign="center">23</td>
</tr>
<tr>
<th>Atlanta</th>
<td>Departures</td>
<td valign="center">36</td>
</tr>
<tr>
<th>Atlanta</th>
<td>Unused</td>
<td valign="center">11</td>
</tr>
<tr>
<th>Atlanta</th>
<td>Out of Commission</td>
<td valign="center">7</td>
</tr>
<tr>
<th>Boston</th>
<td>Arrivals</td>
<td valign="center">41</td>
</tr>
<tr>
<th>Boston</th>
<td>Departures</td>
<td valign="center">17</td>
</tr>
<tr>
<th>Boston</th>
<td>Unused</td>
<td valign="center">25</td>
</tr>
<tr>
<th>Boston</th>
<td>Out of Commission</td>
<td valign="center">9</td>
</tr>
</table>
The example below shows data in an HTML table.
Example Data in HTML Table Format (Maps)
<table>
<tr><td>Adelaide</td><td>23</td></tr>
<tr><td>Brisbane</td><td>78</td></tr>
<tr><td>Canberra</td><td>1</td></tr>
<tr><td>Darwin</td><td>55</td></tr>
<tr><td>Hobart</td><td>25</td></tr>
<tr><td>Melbourne</td><td>71</td></tr>
<tr><td>Perth</td><td>9</td></tr>
<tr><td>Sydney</td><td>52</td></tr>
</table>
Note: HTML tables can contain an optional first row with header information. This row is ignored by Corda Server. Rows that have no data values are always ignored.
Each row represents a separate map data item. The first column identifies the map shape to which the data value belongs, while the second column specifies the actual value.
If it's necessary to identify map items by names other than the one specified in the name attribute of the map shape, use its long-name or code attribute instead. For example, a database might store information for a TX object under Texas, or a database might use FIPS codes instead of county or state names.
Any map data items referenced in the data file must already be defined in the Image Template file, or Corda Server ignores all data associated with that reference.
For information about adding map shapes to a map, see Adding Point Layer Data Items and Adding Area Data Items in the Corda Builder User Guide.
HTML tables sometimes contain extraneous rows and columns that Corda Server can ignore. For more information about data filtering, see META Tags.
If you don't know an HTML table number, use the @_SHOWTABLESFROMURL server command to find it. This command returns a list of all tables in a specified Web page, with corresponding table numbers. This is sometimes a good utility to use even if you know the table's number, because Corda Server might not recognize all tables on a Web page (e.g., tables generated by Javascript*).
To use this command, simply browse to the following location, replacing <server URL> with the URL to your Corda Server, and url with the address of the Web page for which you want a table list.
http://<server URL>:2001 /?@_SHOWTABLESFROMURLurl
Corda Server returns a Web page similar to the following:
Important: In order for Corda Server to list the tables in a Web page, it must have permission to read data from the specified path or domain. For more information, see Setting Path Permissions in the Corda 7 Install and Administration manual.
Note: Corda Server cannot load data from a URL through a proxy server.
To import data from HTML tables into graphs, use the loadData() method. To import data from HTML tables into maps, use the loadMapData() method. Both functions are used similarly.
Important: In order for Corda Server to load any kind of file or data source, it must be given permission to read data from the specified path or domain. For more information, see Setting Path Permissions in the Corda 7 Install and Administration manual.
The loadData() method accepts four parameters for importing data from HTML tables:
The name of the graph object into which you want to load the data.
The path and file name of the Web page. This string can be a URL, a file name relative to <document_root>, or an absolute file name using the Universal Naming Convention (UNC).
An empty string (“”).
The number or title of the HTML table from which you want to load data. For example, if you set this parameter to the number 8, Corda Server imports data from the eighth table in the specified Web page. If you set this value to data2, Corda Server imports data from a table whose title attribute is set to data2.
Important: ASP/VBScript requires five parameters. The last parameter is an empty string (““).
For example, to load data from an HTML table named data2 in the Web page http://www.myserver.com/stats.html, use a Corda Embedder method call similar to the following:
myImage.loadData("graph","http://www.myserver.com/stats.html","","data2");
Note: The code above assumes a Corda Embedder object named myImage.
The loadMapData() method accepts four parameters for importing HTML table data:
The name of the map object into which you want to load the data.
The name of the map layer to which you want to send the data. For more information about map layers, see Map Layers in the Corda Builder User Guide.
The path and file name of the Web page. This string can be a URL, a file name relative to <document_root>, or an absolute file name using the Universal Naming Convention (UNC).
The number or title of the HTML table from which you want to load data. For example, if you set this parameter to the number 8, Corda Server imports data from the eighth table in the specified Web page. If you set this value to USTable, Corda Server imports data from a table whose title attribute is set to USTable.
Important: ASP/VBScript requires five parameters. The last parameter is an empty string (““).
For example, to load data from an HTML table named USTable, use a Corda Embedder method similar to the following:
myImage.loadMapData("map","Area","http://www.myserver.com/stats.html","USTable");
Note: The code above assumes a Corda Embedder object named myImage.