Presenting a directory view in HTML

Previous: Traversing the user/group repositories to build a directory view ] [ Top:  ] [ Next: User editor ]

This part might end up being a more general mechanism, given time. Yes, before I get several emails telling me that this problem has already been solved by XSL, I realize that XSL probably already does everything I need. Eventually I will redress that, but for now I need a solution quickly. Now, on the other hand, if you want to do something that uses XSL to do something that's compatible with what I'm doing here, then I want to hear from you.
 
void dirview_show (FILE * out, XML * dv)
{
   XML * elem;
   const char * link;

   elem = xml_firstelem (dv);
   if (!elem) return;

   fprintf (out, "<ul>\n");
   while (elem) {
      if (!strcmp (elem->name, "folder")) {
         fprintf (out, "<li> %s\n", xml_attrval (elem, "label"));
         dirview_show (out, elem);
      } else {
         link = xml_attrval (elem, "link");
         if (*link) {
            fprintf (out, "<li> <a href=\"%s\">%s</a>\n", link, xml_attrval (elem, "label"));
         } else {
            fprintf (out, "<li> %s\n", xml_attrval (elem, "label"));
         }
      }
      elem = xml_nextelem (elem);
   }
   fprintf (out, "</ul>\n");
}
Previous: Traversing the user/group repositories to build a directory view ] [ Top:  ] [ Next: User editor ]


This code and documentation are released under the terms of the GNU license. They are copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.