XML Processing using the Whitebeam Environment

Site Map
 
Home
 
Application Guide
  Quick Start
  PHP and ASP
  Writing Apps
  Applications
  Tutorials
    Replication
    Postgres Interface
    XML Processing
      Introduction
      Overview
      Processing Data
      The XML JavaScript API
      Special Behaviour
      Manual Execution
      XML Macros
      Example
    Using XPath
    Binary Object
    Using HttpRequest
    SmtpRequest
    Session
    Meta Data
    Iterators
    Memb Services
    Page Look&feel
    Authentication+
    Questionnaires
    Message Groups
    Form Handling
  Samples
Reference
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

XML Processing using the Whitebeam Environment

Example

The following simple example shows a JavaScript recursive function that gets the tag tree for the XML tag called 'root' (a dummy table) and then provides a summary of the tree in the web page output.

<html>
   <head>
   <title>Partners</title>

   </head>
   <table rb:id="root">
      <tr>
         <th>Head 1</th>
         <th>Head 2</th>
         <th>Head 3</th>
      </tr>
      <tr>
         <td>row 1, col 1</td>
         <td>row 1, col 2</td>
         <td>row 1, col 3</td>
      </tr>
   </table>

   <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0"
         marginheight="0" text="#000000" >
      <H1>Decoding form parameters.</H1>

      <h1 rb:id="HelloWorld">HEADER</h1>
      <rb:script>
         // define a function to dump one level of the XML tree.
         function dumpTree(tag, spaces) {
            var child;

            rb.debug.write("<p>tag type:"+tag.type+", length="+
                     tag.length+"</p>");
            if (tag.type == "tag") {
               // Its an object so dump its name then recursively
               // display its children.
               rb.page.write("--->"+spaces+"XML Tag:"+
                              tag.name+"<br>");

               for (child in tag) {
                  rb.debug.write("<p>Processing child object:"+
                                  tag[child].type+"</p>");
                  dumpTree(tag[child], spaces+"   ");
               }
            }
            else {
               rb.page.write("--->"+spaces+"Text,
                              length"+tag.length+"<br>");
            }
         }

         var tag = rb.xml.root.findId("root");

         rb.page.write("<p>\n");
         rb.page.write("<h1>Tag Tree Dump</H1><P>");
         rb.page.write('<table border="1">\n');
         dumpTree(tag,"tag");
         rb.page.write('</table>\n');
         rb.page.write("<h1>Tag Tree Dump Complete</H1><P>");
      </rb:script>
   </body>
</html>
Whitebeam release 1.3.36
(loadtime : 8ms)