QString'de tutulan HTML verilerini işlemeye çalışıyorum. Veriler, HTML etiketlerini, örn. "<" vb. Bunları uygun sembollere dönüştürmek istiyorum.QString.replace çalışmıyor
Birçok yaklaşımı deniyorum, ancak hiçbiri işe yaramıyor, bu da gerçekten basit bir şeyi kaçırdığımı gösteriyor.
QString theData = "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Arial'; font-size:20pt; font-weight:400; font-style:normal;">
<table border="0" style="-qt-table-type: root; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;">
<tr>
<td style="border: none;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#4cb8ff;">This is text on the second page. This page contains a embedded image,</span></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; color:#4cb8ff;">and audio.</span></p></td></tr></table></body></html>";
QString t2 = theData.replace("&", "&").replace("<", "<").replace(">", ">").replace(""", "'");
t2 değeri ancak cümledeki sonra theData aynıdır: Burada
(önceki yorum tarafından bildirilen yazım hatalarını düzeltmek için değiştirilen) kodudur.
"t1..replace" <- Geçerli bir C++ sözdizimine benzemiyor. – MrEricSir