Home » Categories » Multiple Categories

Events-Client Side XML Example

The following code is for example only. It is up to the web developer to determine how he/she wants to handle the XML data.
This software is provided "as is", without warranty of any kind, express or implied. In no event shall Evanced Solutions be held liable 
for any direct, indirect, incidental, special or consequential damages arising out of the use of or inability to use this software. 
Evanced Solutions is not obligated to support the code due to the various ways XML is handled between browsers.

Events - Client Side XML example

This example shows how JavaScript can be used to display a window of events on your library's homepage, using the XML feed from the calendar software.

To run this example you will need to copy the 3 included files into a web accessible folder on your web server.

   eventsxml.html --> Example Web page used to display a window of events.
   eventsxml.xsl --> Style Sheet formatting file for XML data.
   getxml.asp --> Server-side page for obtaining the XML data and sending it to the HTML page.

Editing the XSL file is beyond the scope of this example, but many resources can be found on the internet by doing a search on the tags "XSL XML tutorial".

Editing the JavaScript in the HTML file is beyond the scope of this example, but many resources can be found on the internet by doing a search on the tags "JavaScript tutorial".

Editing the ASP file is beyond the scope of this example. If your server is not running ASP you may need to translate this page into server-side script that performs a similar function.


To make this example work properly you will need to edit 4 path variables. The first 3 are in the HTML file. Do a search on the word "REPLACE" to find the 3 locations.

  • The first location looks like this:
<script type="text/javascript" src="http://host.evanced.info/lib/common/zxml.js"></script>

This is a reference to a file included with all Event Calendar installations. If your installation is hosted your path will look something like this:

http://host.evanced.info/YOURLIBRARYNAME/lib/common/zxml.js
  • The 2nd location looks like this:
var xmlcalendarURL="getxml.asp"

This file should reside on the same server as the "eventsxml.html" page. A hard-coded path is not necessary if this file resides in the same folder as the HTML file.

  • The 3rd location looks like this:
var xslcalendarURL="eventsxml.xsl"

This is your XSL formatting file. A default version of this file is included with this example. Your path to this file will probably be something like:

www.YOURLIBRARYWEBSITE.org/WEBFOLDER/eventsxml.xsl

Unless it is located in the same folder as the HTML file and will not need a path.

  • The 4th location is in the getxml.asp file.
xmlpath="http://host.evanced.info/lib/eventsxml.asp?dm=xml&lib=all&alltime=1&nd=14"

This is a link to the XML feed from your calendar system. The example is a link to our training site. If your installation is hosted your path will look something like this:

http://host.evanced.info/YOURLIBRARYNAME/lib/eventsxml.asp

URL switches can be added to this link to specify the data you want returned from this link. In this example are:

   dm=xml  - Format of the returned data
   lib=all  - Use data from all branches
   alltime=1 - Use data from all day
   nd=14  - Use 14 days worth of data

The ASP file is used to perform a server side request for the XML data. if your server does not support ASP you will need to translate the ASP code into a server-side script that is support by your server. The basic concept is: the client HTML page cannot obtain the XML data directly from a different domain (causes an Access Denied error). This server-side ASP file can obtain the data and pass it to the HTML file as a string.

You will need to remove the comments from the beginning of the getxml.asp file. Since the result of this file should be XML, having a comment at the beginning will cause it to not look like XML data. Remove everything down to, but not including the "<%@ LANGUAGE="VBScript"%>"

Once the HTML and ASP file are edited with your path information, you will be able to open the HTML file in a web browser and see how the XML feed can be displayed in a simple table.

Double-clicking the file may open the file but it will also generate an ActiveX error in your browser. To properly test you should enter the URL to the HTML file in a browser window. This will eliminate the error and display the page properly.

To incorporate this into your site you will need to:
1. Modify the 'eventsxml.xsl' file to use the styles of your website.
2. Copy the javascript code from the example and include it on your website.
3. Use the "displayEvents()" function to do the work.

Download the example files here: https://s3.amazonaws.com/static.evanced.info/Examples/Events_Client_side_XML.zip

Custom Fields
  • Applicable To: Admin Users
  • Attachments: No
0 (0)
Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles
Maintaining Event Attendance
Viewed 3395 times since Thu, Oct 6, 2011
Is there Evanced Calendar for Mobile Access?
Viewed 8199 times since Thu, Oct 6, 2011
How to add a logo or website header to my calendar page
Viewed 29693 times since Tue, Sep 27, 2011
Understanding the Waiting List
Viewed 5796 times since Thu, Sep 15, 2011
Adding Facebook Thumbs-up Button to Events
Viewed 10815 times since Wed, Jan 11, 2012
Events Search Widget
Viewed 4682 times since Tue, Jan 3, 2012
How to Subscribe to an Evanced Calendar Using IPhone/IPad
Viewed 19045 times since Wed, Oct 26, 2011