2022.2

Table Of Contents
Tip: ToquicklygetthelocationofanHTMLsnippetinthetemplateresources,right-clickthesnip-
petintheResourcespaneandselectCopy Resource Location.
ThepathtoaremoteHTMLsnippetcanbecopiedfromthesnippet'sproperties:right-clickthe
snippetintheResourcespaneandselectProperties.
selector
String.ThesuppliedselectorshouldconformtoCSSselectorsyntaxandallowsyoutoretrieveonlythe
contentofmatchingelements.
IftheselectedelementisaDynamicTable,theretrievedHTMLwillcontaintheexpandedtable.
Examples
Thisscriptloadsaspecific elementfromasnippetandusesthattoreplacetheresults(theHTML
elementorsetofHTMLelementsmatchedbytheselectorofthescript;see"results"onpage844).
var mysnippet = loadhtml('snippets/snippet-selectors.html','#item3');
results.replaceWith(mysnippet);
Thisscriptloadsthechildrenoftheselectedelement.
var snippet = loadhtml('file:///C:/Users/PParker/Documents/Example.html','foobar').children();
results.replaceWith(snippet);
Thenextscriptloadsaremotesnippet(see"Remotesnippets"onpage251),looksforanH1heading
andusesthattext.
var post = loadhtml('snippets/post.rhtml');
var h1 = query('h1', post).text();
results.text(h1);
Anotherexampleisgiveninthefollowinghow-to:Usingaselectortoloadpartofasnippet.
loadjson()
CreatesaJSONobjectbasedonthetextretrievedfromthesuppliedlocation.Thefunctionletsyou
retrievecontentfromaJSONenabledserverusingastandardHTTPrequest.Popularcontentman-
agementsystemslikeWordPress(requiresJSONAPIplugin)andDrupalprovideaJSONservice/API
toretrievecontent.
Page 728