Nov
27
2011

It’d be great if lottery websites set up APIs, RSS feeds or publicly-accessible JSON data so that web developers could re-publish lottery numbers on their web sites or in their apps. Unfortunately, state and national lotteries don’t have much interest in sending consumers to web sites other than their own to find results/winning numbers.

How to re-publish lottery numbers online

When I first started looking into this issue, I thought that lottery commissions might actually copyright winning numbers. However, a blurb on Saliu seems to indicate they can’t:

“I don’t think a lottery commission will ever claim copyright ownership over its drawings. No religions can claim copyrights over their gods. The lottery draws are ruled by Randomness the Almighty. No entity has copyrights over Almighty Randomness. Anybody can publish things like “These are the winning lotto numbers drawn by this lottery commission on this date…”

What lottery commissions can do, however, is stop your automated script from scraping their site for data by blocking your IP. That means that if you want to publish winning lottery numbers on your site, you’re probably going to have to enter them by hand, or pay someone else who’s entering them by hand to provide you with a feed. I’ve found a few sites online that do just that. I can’t vouch for any of these (and there are lots more out there), but these sites claim to provide accurate lotto numbers that you can re-publish on your site for a fee:

These sites both provide winning lottery numbers in XML, Javascript, HTML, or text.

0 Comments
Feb
10
2009

It’s difficult to grasp the power of XML without understanding what metadata is. Metadata is simply data that describes data. A good example of this is HTML (the Web code that’s allowing you to view this blog). If you’ve seen HTML at all, you’re familiar with some basic tags; these include things like <head>, <body> and <p>. These tags are simply data or information that a Web browser uses to decide how particular lines of text should be formatted. Words that fall between an open bold tag (<b>) and a close bold tag (</b>), for example, are displayed as bold text by the browser. That’s pretty basic stuff. But there’s power in it.

Think about it: why do people bother making text bold? They do it because the words in bold are important. They represent titles, dates, names, etc. So, if you have a document that’s filled with plain and bold text, you’ve got a very rudimentary form of metadata. The plain text is probably less important than the bold text. And, since you’ve got <bold> tags in your data (and content between those <bold> tags), you can manipulate the important text.

This is where things start getting exciting. What if you had a document filled with information, but somewhere inside that information were a bunch of important dates that had been made bold? Suddenly, you could use some search tools (like Ultraedit) to extract all the dates from that document. Then, you could import those dates into a spreadsheet, and use them as a dayplanner.

XML takes these baby steps and starts running with them. See, XML is extensible. That’s where the language got its name: Extensible Markup Language. Once you make a form of metadata like HTML extensible, you’re no longer forced to use very simplistic tags like <b>. You can actually describe the data that’s you’re wrapping inside tags.

For example, if you have a bunch of important dates in your document, you can suddenly wrap them in much more useful tags. Instead of <b>, you could use a tag like <date>. Then, for all of your titles, you could use tags like <title>. See, XML doesn’t lock you into using one set of standardized tags.

Wait a minute, you’re saying, that’s all good and well, but a Web browser can’t interpret tags like <date>. You’re right there, but the lovely folks who brought us XML thought of that, and they came up with a way for us to “transform” our XML documents into whatever format we want whenever we want to transform them. We can do that by using XSLT (Extensible Stylesheet Language Transformations).

Now, let’s say you’ve got an XML document filled with tens of thousands of lines of text, information and tags. You want some of that text to get formatted for your Web page, but you also want some of it to be formatted for a PDF book, and yet more of it you’d like to use as a database. No problem. If you’ve got some stylesheets laying around and an XSLT processor (of which there are free versions like Saxon), you can alter your data easily.

You can write a stylesheet to transform all of your data into HTML. For example, you can convert your <date> tags into <b> tags and all of your <title> tags into <i> tags for italics, and you can keep adding from there. You can wrap everything in <body> and <p> tags, and suddenly you’re ready to throw your data on the Web. You can also format your data for PDF (by outputting XSL-FO), or you can simply use your XML document as a database and query it whenever you like.

Sooooo, the beauty of XML is that it can be used in multiple ways. HTML is good for the Web, but pretty lousy when it comes to using it in other media. Also, HTML doesn’t truly describe the data it’s displaying. XML does, and it still lets you manipulate your data with ease.

These factors are why XHTML is getting so much hype these days. XHTML (which stands for Extensible Hypertext Markup Language), can be used for Internet browsers, but it’s also valid XML. That means, it can be used by other data processors as well (such as Saxon, which I mentioned earlier). Once you allow for that, you’re suddenly able to manipulate your data much easier and put it to use in other media (often with minimal effort). Therein, lies the full power of XML.

Thirsty for more on XML? Check out XML.com, one of my favorite resources when I’m stuck on a problem. Or get a book like Beginning XML (published by Wrox, 2007).

0 Comments