Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the first 200 characters of a string without breaking HTML tags at the end
    text
    copied!<p><strong>EDIT</strong>: The key point is about getting the first 200 characters and closing all tags, that are left open.</p> <hr> <p>I'm currently loading articles from other website via DOM object (the other website have no RSS). I want to make a "preview" of that article, but here are my problems:</p> <ol> <li><p>I do not control how the articles are written, therefore it seems to always be inside a table on the second TR (they use a CMS and it is messy - see example below).</p></li> <li><p>They have A LOT of HTML tags, I don't want to leave one open.</p></li> <li><p>I need to keep the HTML format, I know it's ugly but it fits perfectly in my page.</p></li> </ol> <p>Not my code (in French sorry):</p> <pre><code>&lt;table&gt; &lt;TR &gt; &lt;TD class='Normal' valign="top" colspan="2" style="padding-bottom:15px;"&gt;13-01-2012 &lt;b&gt;Water-polo – Championnat pan-pacifique&lt;b &gt;&lt;/TD&gt; &lt;/TR&gt;&lt;TR &gt; &lt;TD class='Normal' valign="top"&gt;&lt;span class="HeadTitleNews"&gt; Les Canadiennes disputeront le bronze aux Chinoises&lt;/span&gt; &lt;img src='http://www.sportcom.qc.ca/Portals/0/2011WaterpoloF.jpg' width='165' align='right' class='imgAnnouncementCss'&gt;&lt;div style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: Tahoma; font-size: 10pt"&gt;Montr&amp;eacute;al, 13 janvier 2012 (Sportcom) &amp;ndash; L&amp;rsquo;&amp;eacute;quipe f&amp;eacute;minine canadienne de water-polo a remport&amp;eacute; une victoire &amp;eacute;crasante de 19-3 face au Br&amp;eacute;sil, vendredi, au Championnat pan-pacifique de Melbourne, en Australie. Les Canadiennes se sont ainsi assur&amp;eacute;es de participer au match pour la m&amp;eacute;daille de bronze contre les Chinoises. &lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt"&gt;&lt;span style="font-family: Tahoma; font-size: 10pt"&gt;La Montr&amp;eacute;alaise &lt;strong&gt;Sophie&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="font-family: Tahoma; font-size: 10pt"&gt; Baron-La Salle&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family: Tahoma; font-size: 10pt"&gt; a marqu&amp;eacute; quatre buts dans la victoire. &lt;/span&gt;&lt;/div&gt; &lt;div style="margin: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/div&gt; </code></pre> <p>Thanks.</p>
 

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