有大神用过PHP Simple HTML DOM Parser这个吗 求指教
ringa_lee
ringa_lee 2017-04-10 15:19:42
[PHP讨论组]

如何用这个获取

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="titleTop2">
    <tr>
        <td class="pageAlign">
            <table cellpadding="0" width="100%" class="displayTag" cellspacing="1" border="0" id="user">
                <thead>
                    <tr>
                        <th align="center" width="10%" class="sortable">课程号</th>

获取到 课程号 这三个字

ringa_lee
ringa_lee

ringa_lee

全部回复(2)
天蓬老师
php
$html = >>>XML <table> <th align="center" width="10%" class="sortable"> 课程号 </th> </table> XML $xml = simplexml_load_string($html) $ths = $xml->xpath("/table/th/[@category='sortable']") print_r($ths[0]) // 课程号

顺便给你找了一条 xpath 资料

如果你使用过 jquery 的话,可以试试 phpQuery

黄舟
$html = "<table>...</table>";
$htmlObject = str_get_html($html);
$th = $htmlObject->find('th', 0);
$text = $th->plaintext;

官方文档,实例详尽:http://simplehtmldom.sourceforge.net/manual.htm

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号