2005-04-03 Wikis

I’m starting to rewrite some of the unit tests for Oddmuse. Whenever the test specified an HTML element with various attributes, I had written it as string-match or as a regular-expression match. On my iBook, the CGI library seems to be a bit different and now I’m finding that the attributes within an element can change order, eg. what used to be blarg<*a> is now blarg. So what I’m doing now in these cases is I parse the HTML output using XML::LibXML, and use findnodes() with an XPath expression.*

Example:

**code**xpath_test(get_page(’CacheTest’), ’_a[@class=”edit”][@title=”Click to edit this page”][@href=”http://localhost/wiki.pl?action=edit;id=WikiLink”][text()=”?”]’); _

http://localhost/wiki.pl?action=edit;id=WikiLink

It ain’t pretty, but I think this will improve the unit tests, so I’ll just have to bite the bullet and do it.

​#Wikis