Monthly Archive for March, 2006

Library

I played around with DOM on a “library” stored in XML. You can check that out here.

SimpleXML is a Wonderful Thing

Today I found out about SimpleXML. It’s a “toolset” built-in to PHP 5. It makes reading an XML file and access data really, really easy. The “library” XML parser I wrote up before, with all that startElement and endElement crap, was 158 lines. Using SimpleXML to do the same thing? 33 lines.

Frickin’ sweet!

View the page or the source code.

Commenting Your Code

In Practical Common Lisp Peter Seibel writes a little about proper form. He mentions comments and I like his style. In Lisp, he says, you denote a comment with a semi-colon (;). You start a
comment with one to four of these, so that some sense of scope is available.

You start a line with four semi-colons if it applies to the whole file.
;;;; This file contains all the functions for ...

Use three semi-colons to comment large sections of code.
;;; Here are the functions for searching and sorting ...

Two semi-colons comment on the code that immediately follows.
;; Ensure that digits are padded with 0s.

And one semi-colon applies to just that line.
; Statistics, number of changed items

I think that’s pretty slick and I think it can (and should) be applied anywhere, regardless of the language. I’m going to make an effort to start using this in my PHP and LotusScript.

Library Fix Up

I cleaned up the PHP code that parses the XML file and displays it. It does the same thing, but I removed debugging information and added some comments. You can view the page here and the source here.

What I want to do next is create a form that will allow you to add information to the XML file. Oo.

PHP and XML

I had some time to play around with using PHP and XML. Right now I have a PHP page that reads from and XML file and uses PHP’s XML parser to handle the data. I have some objects to contain data, and then I reorganize it and display it in a table. It’s not really complicated, but it’s new to me and I think it’s cool. You can view the XML file with the XSL associated with it here. If you view the page source for that, you’ll see the raw XML. You can see the PHP page that parses, massages, and displays the data here and the source code here. The source is a bit of a mess because I had time to make it work but not really any time to make it pretty. When I get a chance to work on it some more I’ll put in some comments and make things make some sense.

Fun With XSL

Yesterday I started fooling around with XSL. Here’s the XML file. Here’s my first XSL file, and here’s the second. To see them in action, check out this and this.

My First Lisp

I have only now managed to get through the second chapter of Practical Common Lisp. I am compiling my own Emacs cheatsheet. Here’s my first Lisp program.

(defun hello-world ()
  (format t "Hello, world!"))