:: JS XML Document Reader  Author Joe McCormack

Examples of XML Data Imported Into This Web Page:

ANNOUNCEMENT, AD, ETC:
You can place this anywhere on your webpage to have the XML data inserted.
<!-- XML Announcement Placement -->
<DIV ID="dannouncexml" style="position:relative;visibility:visible;"></DIV>
<XML ID="announceXML" src="announce.xml" ondatasetcomplete="getRecords('links','announceXML','dannouncexml');" />
Look at the FILE XML source.
TEXT HYPERLINKS:
You can place this anywhere on your webpage to have the XML data inserted.
<!-- XML LINKS INFORMATION PLACEMENT -->
<DIV ID="dlinksXML" style="position:relative;visibility:visible;"></DIV>
<XML ID="linksXML" src="pagelinks.xml" ondatasetcomplete="getRecords('links','linksXML','dlinksXML');" />
Look at the FILE XML source.
EMAIL HYPERLINK WITH DETAILS:
You can place this anywhere on your webpage to have the XML data inserted.
<!-- XML FOOTER INFORMATION PLACEMENT -->
<DIV ID="dfooter" style="position:relative;visibility:visible;"></DIV>
<XML ID="footerXML" src="footer.xml" ondatasetcomplete="getRecords('email','footerXML','dfooter');" />
Look at the FILE XML source.

Why Import Data In Real-time Into Web Pages?:

If you have sections of your web pages that are frequently updated, such as a table of links, or you have advertising, announcement, or message spots that change, it can be easier (by far) to simply change one file instead of dozens or even hundreds of web pages. That is why I created the JS XML DOCUMENT READER. It can make updating and maintenance much simpler for you.

Typical Usage Answers:

After examining the examples above, you may be asking yourself some questions that can be answered here. First, each one of the examples (by placing data into the appropriate XML field) can have a combination of things even though each example does not show all the features. For example, each one can have an image. Each one can have a linked image (by http or mailto). Each one can have a title. And each one can have a description attached to it.

To activate any combination to be displayed (the script actually determines what is shown based on what is completed in the XML file), simply update the appropriate fields in the XML file. An XML file can be edited and saved with a text editor such as Notepad.

Step One: Determine how many XML files to use

In order to determine what you what to have in your XML files, you must know what needs to be placed in what fields. How many XML files that you use is up to you, but keep these points in mind:

Step Two: Create an XML file

To be understood by the script (which you do not need to change for it to work), your XML file should be of the following format:
An XML File With A Single Entry:
An XML File With Multiple Entries:
<?xml version="1.0"?>
<BBLOCK>
    <RENDER>
       <A>Title Here</A>
       <B>Description Here</B>
       <C>Hyperlink Here</C>
       <D>Image Link Here</D>
    </RENDER>
</BBLOCK>
<?xml version="1.0"?>
<BBLOCK>
    <RENDER>
       <A>Item 1 - Title Here</A>
       <B>Item 1 - Description Here</B>
       <C>Item 1 - Hyperlink Here</C>
       <D>Item 1 - Image Link Here</D>
    </RENDER>
    <RENDER>
       <A>Item 2 - Title Here</A>
       <B>Item 2 - Description Here</B>
       <C>Item 2 - Hyperlink Here</C>
       <D>Item 2 - Image Link Here</D>
    </RENDER>
</BBLOCK>
NOTE: You do not need the "Item 1 - " or "Item 2 - " text in the fields. This was only inserted to show the scope of each entry.
REMEMBER: If you include a hyperlink, give the URL without the http: prefix. If you include an email address, give the email address without the mailto: prefix. (The "email" or "links" parameter specifies what to use).
ALSO REMEMBER: If there are any fields that you do not want to show up, simply leave those fields blank in the XML file.

Step Three: Add the link to the JS XML Document Reader on each of your web pages

In order to use the JS XML Document Reader control on your web site you need to follow these steps:

  1. Download the xmlreader.js file into your computer. Usually you will want to place the control in the same folder as the web pages that will call it.
  2. Place the following javascript code between the <HEAD> and </HEAD> tags of your web page(s):
    <script language="javascript" src="xmlreader.js">
    <!--
    /*
      JS XML Document Reader. Author Joe McCormack. Copyright 2003. All Rights Reserved.
      www.geocities.com/code_stratos/
    */
    //-->
    </script>

Use Summary:

Use this outline if you are having trouble determining what needs to be done to be able to have data inserted into your web pages in real-time.

  1. Determine what content on your web page(s) you want to have imported from an XML file(s).
  2. At that location on the web page(s), insert the javascript code block (see three different examples at the top of this page). Update the appropriate fields in that code (as shown under Step 1 above).
  3. Create the XML data file with the fields customized to your scope (as shown under Step 2 above).
  4. Finally, add the JS link to each of your web page(s) that XML data will be inserted into (as shown under Step 3 above).

1