dongzhi8487 2012-07-13 09:56
浏览 47

在HTML标记范围中删除属性

I'm fetching data through CURL request and while parsing the HTML I'm some spans having attributes are not being parsed neatly.

Snippet of HTML code

<div class="ftlt" style="width:250px;">
    <div class="tdiv"><span class="prop_price_img"></span><span class="property_price">PROPERTY_PRICE</span></div>
    <p class="adPrice">AREA</p>
    <h4>
      <p style="float:left;width:251px;font-family:Arial, Helvetica, sans-serif;font-size:13px;padding:2px 10px 10px 0px;"><a href="some link" title="title">TITLE</a>,
                  <span style="color:#666;"> CITY_NAME.</span> 

                <a title="title, Sale" style="color:#3266CC;font-size:12px;text-decoration:underline;">View on map</a></p>
    </h4>
    <p style="font-weight:bold;color:#666;">
           Premium
          </p>
    <div class="clr"></div>
  </div>

I have to access the CITY_NAME element neatly. I have been able to fetch that node through HTML DOM as

$spans = $html->find(div.ftlt span);
$city_value=strip_tags($spans[2]);

This $city_value is getting morphed. I've tried removeAttribute method.Maybe I'm not doing it properly.

If regex can be applied, I want to know how?

  • 写回答

1条回答 默认 最新

  • dqbn76906 2012-07-13 10:04
    关注
    $spans = $html->find(div.ftlt span);
    $city_value=$spans[2]->nodeValue;
    

    Why don't you use nodeValue?

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度