2019.2

Table Of Contents
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 page738), 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
l The specified JSON file is expected to be UTF-8 encoded.
l Loadjson() is cached per batch run (based on the URL) in print/email.
l This online JSON viewer is handy to debug JSON data: http://jsonviewer.stack.hu
Tip
External content is not loaded while editing a script. To test a script that loads external content, you
can do a preflight; see "Doing a Preflight" on page864.
loadjson(location)
Loads json data from the specified location.
location
Page 1342