2018.2

Table Of Contents
Examples
This script loads a specific element from a snippet and uses that to replace the results (the
HTML element or set of HTML elements matched by the selector of the script; see "results" on
page1192).
var mysnippet = loadhtml('snippets/snippet-
selectors.html','#item3');
results.replaceWith(mysnippet);
This script loads the children of the selected element.
var snippet = loadhtml
('file:///C:/Users/PParker/Documents/Example.html','foobar').childr
en();
results.replaceWith(snippet);
The next script loads a remote snippet (see "Remote snippets" on page642), looks for an H1
heading and uses that text.
var post = loadhtml('snippets/post.rhtml');
var h1 = query('h1', post).text();
results.text(h1);
Another example is given in the following how-to: Using a selector to load part of a snippet.
loadjson()
Creates a JSON object based on the text retrieved fromthe suppliedlocation. The function lets
you retrieve content from a JSON enabled server using a standard HTTP request. Popular
content management systems like WordPress (requires JSON API plugin) and Drupalprovide
a JSON service/API to retrieve content.
Note
Loadjson() is cached per batch run (based on the URL) in print/email.
This online JSON viewer is handy to debug JSON data: http://jsonviewer.stack.hu
Page 1151