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 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短