CodeIgniter Forums
xml_convert error in long space and end content in javascript 4.5.4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: xml_convert error in long space and end content in javascript 4.5.4 (/showthread.php?tid=91605)



xml_convert error in long space and end content in javascript 4.5.4 - startup - 09-04-2024

in this case, code working
PHP Code:
$rm_question  trim(preg_replace('/\s+/'' 'xml_convert($cauhoi))); 

in javascript show:
Code:
learntips: '<p>Chọn <strong>đáp án 2</strong> trong mẹo nhé.</p>

in this case, code dont work so middle space in the content and end content
PHP Code:
$rm_question  =  xml_convert($cauhoi))); 

Code:
<p>Chọn <strong>đáp án 2</strong> trong mẹo nhé.</p>

<p><u><strong>Mẹo hành vi sai bị nghiêm cấm, không được khi tham gia giao thông</strong></u></p>

<ol>
<li>Cố ý làm hỏng</li>
<li>Buông cả hai tay</li>
<li>Trên cầu hẹp một làn xe</li>
<li>Đi vào phần đường dành cho người đi bộ</li>
<li>Chạy quá tốc độ tối đa cho phép</li>
<li>Lạng lánh đánh võng</li>
<li>Vận chuyển trái phép hàng nguy hiểm, hàng cấm</li>
<li>Đe dọa, xúc phạm, xâm phạm</li>
</ol>

I don't know if function helper xml_convert will add trim and remove all spaces in the future


RE: xml_convert error in long space and end content in javascript 4.5.4 - kenjis - 09-04-2024

I don't know what is wrong.


RE: xml_convert error in long space and end content in javascript 4.5.4 - startup - 09-04-2024

(09-04-2024, 09:08 PM)kenjis Wrote: I don't know what is wrong.
Currently xml_convert function is not wrong, but to improve the helper better, the dev can  remove long spaces including the beginning and end of the content, which will be better for programmers.

as above example code dont work if  remove all long spaces in the content, it will work
Code:
<p>Chọn <strong>đáp án 2</strong> trong mẹo nhé.</p><p><u><strong>Mẹo hành vi sai bị nghiêm cấm, không được khi tham gia giao
thông</strong></u></p><ol><li>Cố ý làm hỏng</li><li>Buông cả hai tay</li><li>Trên cầu hẹp một làn xe</li><li>Đi vào phần đường dành cho người đi bộ</li><li>Chạy quá tốc độ tối đa cho phép</li><li>Lạng lánh đánh võng</li><li>Vận chuyển trái phép hàng nguy hiểm, hàng cấm</li><li>Đe dọa, xúc phạm, xâm phạm</li></ol>



RE: xml_convert error in long space and end content in javascript 4.5.4 - kenjis - 09-04-2024

I still don't know what is your issue. Can you describe the issue more clearly?
What is wrong in the current output?

I think xml_convert() does not convert spaces.
See https://codeigniter4.github.io/CodeIgniter4/helpers/xml_helper.html#xml_convert