Convert A Html String To Dom And Then Dom To Formatted Text
I have used an RtfToHtml Converter in order to print some text into my table cell. it converts successfully, then i want this converted text (geResult.NotesLong) to be formatted:
Solution 1:
Your code ends like this:
[...]</P><P /></DIV>
There's an error, it shoud be
[...]</P></P></DIV>
(second closing p
tag wrong /
position)
ADDITION: Actually, that second closing p tag is one too much - there's only one opening p
tag in the code you posted - erase it.
Solution 2:
Finally i have found a way to extract plain text from inside (but it is still missing formats)
html page
<td><script>{ setCommentValue(@colIndex, @rowIndex, @totalColCount, '@geResult.NotesLong', '@geResult.Color');}</script></td>
javascript
functionsetCommentValue(colIndex, rowIndex, assessmentLength, resultValue, color) {
String.prototype.replaceAll = function (search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
//replace all text special charactersvar replaced = resultValue.replaceAll("&", "&").replaceAll(">", ">").replaceAll("<", "<").replaceAll(""", "\"").replaceAll("'", "\'");
var parser = newDOMParser();
var doc = parser.parseFromString(replaced, "text/xml");
....
$(".test").get(elementPos).innerHTML = doc.firstChild.textContent;
}
My text had special characters like > for > etc so i replaced them manually.
Post a Comment for "Convert A Html String To Dom And Then Dom To Formatted Text"