web.Text(source : str, xpath : str, namespaces : map, xml : bool, ttl: num) : str
Convert source to text by optionally fetching and parsing it.
1.9.0 or later
| Name | Type | Description |
| source | str | source text or source uri |
| xpath | str | (optional, default: none) xpath to value. |
| namespaces | map | (optional, default: none) XML namespace definitions (1.9.0b or later) |
| xml | bool | (optional, default: false) capture enclosing XML element (1.9.1 or later) |
| ttl | num | (optional, range: 60 - 86400, default: 300) Caching durations in seconds (8.08 or later) |
The result of web.text depends on the combination of arguments provided. If source is not a URI and xpath is omitted, web.text simply returns source as its result. If source is not a URI and xpath is provided, then web.text behaves like xml.text by parsing source as an XML document and applying the xpath expression (see xpath note below). If source is a URI and xpath is omitted, then web.text fetches the data from the URI as text and returns it. If source is a URI and xpath is provided, then web.text fetches the data from the URI as an XML document and applies the xpath expression.
When applying the xpath expression, web.text returns only the contents of the text nodes that are immediate children of the first XML node matched by the xpath expression. If the first matched XML node is an XML attribute, the value of the attribute is returned instead. If the xml argument is set to true, web.text returns the entire XML node rendered as text.
NOTE: all web.* functions are limited to reading at most 500KB of data from a URI.
| Output | ||
| <ul><li>item 1</li><li>item 2</li></ul> | |
| ||
|
<extension>
<title>Scratch Extension</title>
<label>Scratch</label>
<copyright>Copyright (c) 2006-2010 MindTouch Inc.</copyright>
<description>This extension contains functions for embedding Scratch applications.</description>
<uri.help>http://developer.mindtouch.com/App_Catalog/Scratch</uri.help>
<uri.logo>http://scripts.mindtouch.com/logos/scratch-logo.png</uri.logo>
<function>
<name>scratch</name>
<description>Embed a Scratch application.</description>
<param name="id" type="str">Application User/ID.</param>
<param name="width" type="num" optional="true">Application width. (default: 482)</param>
<param name="height" type="num" optional="true">Application height. (default: 387)</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<body>
<applet id="ProjectApplet" style="display:block" code="ScratchApplet" codebase="http://scratch.mit.edu/static/misc" archive="ScratchApplet.jar" eval:width="web.size(args.width ?? 482)" eval:height="web.size(args.height ?? 387)">
<param name="project" eval:value="'../../static/projects/' .. args.id .. '.sb'" />
</applet>
<a eval:href="'http://scratch.mit.edu/projects/' .. args.id">Learn more about this project</a>
</body>
</html>
</return>
</function>
</extension>
|
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by