ActionsDev

2 replies to this thread. Most Recent

Ian Webb

23 Mar 2020, 11:50 am

[Pro] Strip everything except content of Body tag

Hi!

I’ve been playing with the code given in the Actions Reference PDF to try to strip a page down to just the Body contents.

I’ve got this far:

var doctypeTag = fwDocument.fwTags.fwFind(‘!DOCTYPE’);

doctypeTag.fwDelete();

body = fwDocument.fwTags.fwFind(“body”);

bodyContent = body.fwFindAllContent();

html = fwDocument.fwTags.fwFind(“html”);

html.fwDelete();

fwDocument.fwTags.fwMove(bodyContent);

But it only outputs the Table tag, not any of its TR contents.

Any ideas?

Cheers, Ian.

waltd

23 Mar 2020, 2:41 pm

I would take a look at the PHP Make Insert Page Action for some reference code. https://actionsforge.com/actions/php-make-insert-page Check the source to ensure that there are some updates in it from me (last one was in 2010). If you don’t see that, please let me know.

Walter

On Mar 23, 2020, at 7:50 AM, Ian Webb via actionsdev <[email protected]> wrote:

Hi!

I’ve been playing with the code given in the Actions Reference PDF to try to strip a page down to just the Body contents.

I’ve got this far:

var doctypeTag = fwDocument.fwTags.fwFind(‘!DOCTYPE’);

doctypeTag.fwDelete();

body = fwDocument.fwTags.fwFind(“body”);

bodyContent = body.fwFindAllContent();

html = fwDocument.fwTags.fwFind(“html”);

html.fwDelete();

fwDocument.fwTags.fwMove(bodyContent);

But it only outputs the Table tag, not any of its TR contents.

Any ideas?

Cheers, Ian.

Freeway user since 1997

http://www.walterdavisstudio.com

Back to Top

Ian Webb

23 Mar 2020, 3:24 pm

Hi Walter!

Thanks, that got it! I think the bit I was missing out was the ‘enclosesHTML’ part but, to be honest, I still don’t understand how it works!

I’ve posted it to ActionsForge: https://www.actionsforge.com/actions/strip-head-body-tags

Cheers, Ian.