[erlang-questions] kick start a newb!

Dustin Whitney <>
Thu Feb 7 05:57:39 CET 2008


I'd really like to get into Erlang, but I'm stumbling over some UTF 8
troubles.  Could someone please explain to me why the code below results in
a list of integers instead of the XML document I'm supposed to get (I think
it has something to do with UTF8), I'd really appreciate it.  The second
listing of code works just fine, and I believe it works because slashdot
encodes their data in iso-8859-1.   How can I output UTF8 in a format that
is readable?  And, ultimately I want to run an XPath query against the XML
document I get from the GET request... baby steps I suppose.  Any help would
be great, especially links to documentation!

Thanks,
Dustin

Listing #1

-module(tmp).
-export([get_url/0]).

get_url() ->
    {_,{_, Header, Body}} = http:request("
http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=PREFIX+xsd%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0APREFIX+dbpedia2%3A+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2F%3E%0D%0A%0D%0ASELECT+*+WHERE+%7B%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FCity108524735%3E.%0D%0A%3Fsubject+rdfs%3Alabel+%3Flabel.%0D%0A%3Fsubject+dbpedia2%3Apopulation+%3Fpopulation.%0D%0AFILTER+%28lang%28%3Flabel%29+%3D+%22en%22+%26%26+xsd%3Ainteger%28%3Fpopulation%29+%3E+200000%29%0D%0A%7D&format=application%2Fsparql-results+xml&debug=on
"),
    Body.



Listing #2

-module(tmp).
-export([get_url/0]).

get_url() ->
    {_,{_, Header, Body}} = http:request("http://slashdot.org"),
    Body.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080206/e8cfff68/attachment.html>


More information about the erlang-questions mailing list