MySQL查找和替换HTML DOM标签
有如下一个html字符串保存在mysql数据库中:
<div> <p>文本</p> <figure>广告<imgsrc="a.jpg"/></figure> <p>文本</p> </div>
现在要从数据库数据中删除中间的广告标签,如何用mysql语句实现?
我们要用到两个主要函数:LOCATE和INSERT。
第1步一句mysql查找
首先,如果我们用一句mysql语句:
select
Insert(
post_content,
Locate('<figure>',post_content),
Locate('</figure>',post_content,Locate('<figure>',post_content))-Locate("<figure>",post_content)+LENGTH('</figure>'),
''
)
asnew_contentfromwp_postswhereID=146;
- LOCATE(
substr,str)
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短