Skip to content

tom-clik/coldsoup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coldsoup

CFML wrapper for JSoup.

Introduction

Working with JSoup in CFML often requires JavaCasting variables and quite cumbersome syntax. This component provides some simpler CFML methods.

Usage

Assumes Jsoup is installed in your server class path.

  1. Instantiate the component as a singleton in a shared scope, e.g. application

    application.coldsoup = new coldSoup();
  2. Call static methods as required, e.g.

    myDoc = application.coldsoup.parse(html);
  3. Return type from parse() is a Jsoup Document.

    These can be searched with select(selector) where selector is a JQuery-like selector, e.g. p.class. The return value is sufficiently like a CF array to be used as one. Each element is a Jsoup Node. Modern versions of Jsoup should return an empty array if none are found. If you get null values, upgrade.

Examples

Parse html into a document for searching/updating

doc = coldSoup.parse(htmlDocument);
headings = doc.select("h2");
for (heading in headings) {...}

Return cleaned html

html = coldSoup.clean(html="<script>bad code</script> text", whitelist="basic" );

create JSoup node without having to JavaCast everything.

node = coldSoup.createNode("h2","my heading");

For further examples, see samples.

About

CFML Wrapper for Jsoup

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published