remove-content
The remove-content
action is used to remove nodes from a DOM. By default it will use fit://request/content
for input and output.
xpath="..."
or css-selector="..."
for selecting nodes in the document (must have exactly one).in="..."
to define the input location (optional, default is fit://request/content
).out="..."
to define the output location (optional, default is fit://request/content
).The action reads the in
content, changes the document by removing nodes selected by the given xpath
or css-selector
, and writes the changed document to out
. If the document node is selected (for example by using xpath="/"
) the node will not be removed. Instead it will simply be ignored when the selected nodes are removed.
Check the css selector documentation for more information regarding support und utilization.
<flow>
…
<remove-content css-selector="aside" if="viewport/width < 500"/>
…
</flow>
Input:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h1>My Blog</h1>
</header>
<article>
<h1>My Blog Post</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</article>
<aside>
<h2>Blogroll</h2>
<ul>
<li><a href="…">My Friend</a></li>
<li><a href="…">My Other Friend</a></li>
<li><a href="…">My Best Friend</a></li>
</ul>
</aside>
</body>
</html>
Output if the condition evaluates to true
:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<header>
<h1>My Blog</h1>
</header>
<article>
<h1>My Blog Post</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</article>
</body>
</html>
The following errors are considered non-fatal. The flow will continue, no content will be written to out
.
xpath
nor a css-selector
attribute is specified.xpath
and css-selector
attributes are specified both.xpath
or css-selector
attribute contains an invalid expression.in
document is missing, empty or no DOM.