在html文本中搜索字符串 [英] search for string in html text

查看:90
本文介绍了在html文本中搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i在运行时有字符串包含这样的html标签

  <   tr  >  <   td  >  <   br  >  
< div style = border:1px solid#999999; width:400px; float:left; margin-removed50px; >
< p style = width:400px; >
< br >
< img src = images / img1.gif style = float:right; >
< / div >
< div class = clear style = height:5px; > < / div >

< table class = normaltable 样式 = margin-removed50px ; border:1px solid#999999; width:400px; float:left; >

< tr >
< td 样式 = text-align:right; color:#21B7E5; > الصانع< / td >
< td > 道奇< / td >
< / tr >


< td style = text-align:right; color:#21B7E5; > بلدالتجميع< / td >
< td > 美国< / td >
< span class =code-keyword>< / tr >
< tr >
< span class =code-keyword>< td style = text-align:right; color:#21B7E5; > عددالسجلات< / td >
< td > 32 < / td >
< / tr >
< /表 >
< / td >
< / tr >
< / table >
< < span class =code-leadattribute> br / >





我希望提取每个属性的价值,如道奇,美国,32



任何人都可以帮助我... ... br />


谢谢

解决方案

可能还有其他可能的选项来解决这个问题,但我能够实现这个使用jQuery的方式 -

 


function (){
var str = ' < table>< tr>< td>< br> < div style =border:1px solid#999999; width:400px; float:left; margin-removed50px;> < p style =width:400px;> <峰; br> < img src =images / img1.gifstyle =float:right;> < / IMG>< / BR>< / P>< / DIV> < div class =clearstyle =height:5px;>< / div> < table class =normaltablestyle =margin-removed50px; border:1px solid#999999; width:400px; float:left;> < TR> < td style =text-align:right; color:#21B7E5;>الصانع< / td> < TD>道奇< / TD> < / TR> < td style =text-align:right; color:#21B7E5;>بلدالتجميع< / td> < td>美国< / td> < /表>< / BR>< / TD>< / TR> < TR> < td style =text-align:right; color:#21B7E5;>عددالسجلات< / td> < TD> 32< / TD> < / TR> < /表> < br />';
var arr = [];


(str).find(' td')。each( function (){
如果

hi all
i have string at the run time contains html tags like this

<tr><td><br>
<div style="border:1px solid #999999; width:400px; float:left;margin-removed50px;">
<p style="width:400px;">
<br>
<img src="images/img1.gif" style="float: right;">
</div>
<div class="clear" style="height:5px;"></div>

<table class="normaltable" style="margin-removed50px; border:1px solid #999999;width:400px;float:left;">

<tr>
<td style="text-align:right;color:#21B7E5;">الصانع</td>
<td>Dodge</td>
</tr>


<td style="text-align:right;color:#21B7E5;">بلد التجميع</td>
<td>United States</td>
</tr>
<tr>
<td style="text-align:right;color:#21B7E5;">عدد السجلات</td>
<td>32</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>



and i want to extract the value of each attribute as Dodge, United States , 32

can any one helps me in this please...

thanks

解决方案

There might be other possible options also to resolve this, but I was able to implement this way using jQuery -


(function() { var str = '<table><tr><td><br> <div style="border:1px solid #999999; width:400px; float:left;margin-removed50px;"> <p style="width:400px;"> <br> <img src="images/img1.gif" style="float: right;"> </img></br></p></div> <div class="clear" style="height:5px;"></div> <table class="normaltable" style="margin-removed50px; border:1px solid #999999;width:400px;float:left;"> <tr> <td style="text-align:right;color:#21B7E5;">الصانع</td> <td>Dodge</td> </tr> <td style="text-align:right;color:#21B7E5;">بلد التجميع</td> <td>United States</td> </table></br></td></tr> <tr> <td style="text-align:right;color:#21B7E5;">عدد السجلات</td> <td>32</td> </tr> </table> <br />'; var arr = [];


(str).find('td').each(function() { if(


这篇关于在html文本中搜索字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆