Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Here is an XSLT solution</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="p[descendant::text()[. = '[READMORE]']]"&gt; &lt;a href="#ReadmoreWrapper"&gt;READMORE&lt;/a&gt; &lt;div class="wrapper" id="#ReadmoreWrapper"&gt; &lt;xsl:apply-templates select="following-sibling::node()" mode="copy"/&gt; &lt;/div&gt; &lt;/xsl:template&gt; &lt;xsl:template match= "node()[ancestor::p[descendant::text()[. = '[READMORE]']] or preceding::p[descendant::text()[. = '[READMORE]']] ] "/&gt; &lt;xsl:template match="node()|@*" mode="copy"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*" mode="copy"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when this transformation is applied on the following XML document</strong>:</p> <pre><code>&lt;html&gt; &lt;p&gt; &lt;font face="Georgia"&gt; &lt;b&gt;History&lt;/b&gt;&lt;br/&gt;&amp;#xA0; &lt;br/&gt;Two of the polysaccharides used in the manufacture of...&lt;/font&gt; &lt;a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank"/&gt; &lt;font face="Georgia"&gt;) and this web site for new development by...well as Self Affirmed Medical Food GRAS status.&amp;#xA0; &lt;/font&gt; &lt;/p&gt; &lt;p&gt; &lt;font face="Georgia"&gt;[READMORE]&lt;/font&gt; &lt;/p&gt; &lt;p&gt;&lt;font face="Georgia"&gt;&lt;br/&gt;&lt;strong&gt;Proprietary Composition&lt;/strong&gt;&lt;br/&gt; &lt;br/&gt;The method in which soluble fibres are made into... REST OF ARTICLE... &lt;/font&gt; &lt;/p&gt; &lt;/html&gt; </code></pre> <p><strong>the wanted result is produced</strong>:</p> <pre><code>&lt;html&gt; &lt;p&gt; &lt;font face="Georgia"&gt;&lt;b&gt;History&lt;/b&gt;&lt;br/&gt; &lt;br/&gt;Two of the polysaccharides used in the manufacture of...&lt;/font&gt; &lt;a title="PubMed" href="http://www.www.gov/pubmed/" target="_blank"/&gt; &lt;font face="Georgia"&gt;) and this web site for new development by...well as Self Affirmed Medical Food GRAS status. &lt;/font&gt; &lt;/p&gt; &lt;a href="#ReadmoreWrapper"&gt;READMORE&lt;/a&gt; &lt;div class="wrapper" id="#ReadmoreWrapper"&gt; &lt;p&gt; &lt;font face="Georgia"&gt;&lt;br/&gt;&lt;strong&gt;Proprietary Composition&lt;/strong&gt;&lt;br/&gt;&lt;br/&gt;The method in which soluble fibres are made into... REST OF ARTICLE... &lt;/font&gt; &lt;/p&gt; &lt;/div&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload