Reputation: 43
I need to get the text between html tags in SQL.
< em> " **Test,Extract Me** " < /em>
This is just a small part of html body where the unique identifier is < em>"
Please help
Upvotes: 4
Views: 7493
Reputation: 373
SELECT SUBSTRING(ColumnName,CHARINDEX('html_tag',ColumnName)+LEN('html_tag'), CHARINDEX('html_close_tag',ColumnName) - CHARINDEX('html_tag',ColumnName) - LEN('html_close_tag') +1) FROM TableName
In case the marked answer query doesn't work.
Upvotes: 0
Reputation: 369
SELECT SUBSTRING(ColumnName,CHARINDEX('html_tag',ColumnName)+LEN('html_tag'),CHARINDEX('html_close_tag',ColumnName)-LEN('html_close_tag')) FROM TableName
please replace html_tag,html_close_tag with your tags.
Upvotes: 4
Reputation: 126
I think you want to take a substring of the column value. You can try something like this:
SELECT SUBSTRING(ColumnName, 5, LEN(ColumnName) - 5) AS TrimmedValue FROM TABLE;
Upvotes: 2
Reputation: 668
With using JQUERY you can find easily with simple one line of code :
$('em').text();
You can do the same with simple JS as well
document.getElementsByTagName('em')[0].innerText
Upvotes: -2