[uf-discuss] UfXtract - more than one format at once
Glenn Jones
glenn.jones at madgex.com
Fri Jul 30 08:49:56 PDT 2010
Hi All
André Luís wrote
> One minor gripe, though... can't we ask for transformation for more than one format at once? Optimus does this. And it's kinda useful to avoid more than one requests per URI... :)
OK I have added parsing more than one microformat to the UfXtract API. You have always been able to do this with the .Net library I just did not build it into API. The API format parameter can now takes either a single value or comma delimited list as the example below.
http://ufxtract.com/api/default.aspx?url=http%3A%2F%2Fwww.glennjones.net%2Fabout%2F&htmlfragment=&orginurl=http%3A%2F%2F&format=hcard%2Cxfn%2Chreview%2Chcalendar%2Chatom%2Chresume%2Cgeo%2Cadr%2Ctag%2Cnofollow%2Clicense%2Cdirectory%2Chome%2Cenclosure%2Cvotelinks&output=json&report=on
The .Net library code looks like this:
using UfXtract;
string url = "http://www.glennjones.net/about/";
UfWebRequest webRequest = new UfWebRequest();
ArrayList formatArray = new ArrayList();
formatArray.Add(UfFormats.HCard());
formatArray.Add(UfFormats.Xfn());
formatArray.Add(UfFormats.Adr());
formatArray.Add(UfFormats.License());
...etc
webRequest.Load(url, formatArray);
if (webRequest.Data.Nodes.Count > 0)
{
UfDataToJson dataConvertor = new UfDataToJson();
Response.ContentType = "application/json";
Response.Write(dataConvertor.Convert(webRequest.Data, formatArray));
}
It's about twice as slow running all the microformats formats at once than just one at once. That said I am only talking about an extra 50ms.
Glenn
More information about the microformats-discuss
mailing list