Name

loadString — Fetch a string from a URL

Usage

URL.loadString(url, type)

url : String

type : String

Description

Attempts to fetch the text resource pointed to by the URL url. The MIME content type of the resource must match type, and type must be a text type (must start with text/). If successful, the resource is converted to a string and returned. If the load fails, or the type of the resource doesn’t match type, an integer error code is returned. This code depends on the URL scheme. For HTTP, it’s an HTTP response code.

Returns invalid if either argument can’t be converted to a string. Returns invalid if type isn’t a text type or specifies more than one content type.

Examples

URL.loadString("http://wap.net/cgi-bin/word.cgi", "text/plain")

returns string "EXAMPLE"

URL.loadString("nonexistent", "text/plain")

returns integer 404

URL.loadString("foo", "text/*")

returns invalid

URL.loadString("foo", "image/wbmp")

returns invalid

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.