Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解析HTML';br';用PHPDomXPath标记?_Php_Html_Parsing_Domxpath - Fatal编程技术网

如何解析HTML';br';用PHPDomXPath标记?

如何解析HTML';br';用PHPDomXPath标记?,php,html,parsing,domxpath,Php,Html,Parsing,Domxpath,我有以下HTML示例要用PHP解析,但在尝试解析“br”标记之间的数据时遇到问题: <div id="dump-list"> <div class="dump-row"> <div class="dump-location odd" data-jmapping="{id: 35, point: {lng: -73.00898601, lat: 41.71727402}, category: 'office'}"> <div clas

我有以下HTML示例要用PHP解析,但在尝试解析“br”标记之间的数据时遇到问题:

<div id="dump-list">    
<div class="dump-row"> 
 <div class="dump-location odd" data-jmapping="{id: 35, point: {lng: -73.00898601, lat: 41.71727402}, category: 'office'}">

    <div class="SingleLinkNoTx">
    <a href="#10" class="loc-link">Acme Software</a><br/><strong>John Doe, MBA</strong><br/>123 Main St.<br />New York, NY 10036<br /><strong class="telephone">(212) 555-1234</strong><br/>
    </div><!-- END.SingleLinkNoTx -->

    <a href="http://www.example.com" target="_blank" class="web_link">Visit Website</a><span><br />(0.3 miles)</span>   
    <div class="loc-info">
             <div class="loc-info-text ">
        John Doe, MBA<br /><a href="http://maps.google.com/?daddr=41.71727402,-73.00898601" target="_blank">Get Directions &raquo;</a>    
         </div>

    </div>

</div>
句柄来解析'a href'标记,但是'br'呢?我试过这个:

//br[@class="loc-link"]//text()
但这不会返回任何输出

如何解析以下
HTML
以提取

标记之间的数据(公司名称、所有者、街道地址、城市、州、邮政编码)

<div class="SingleLinkNoTx">
<a href="#10" class="loc-link">Acme Software</a><br/><strong>John Doe, MBA</strong>  <br/>123 Main St.<br />New York, NY 10036<br /><strong class="telephone">(212) 555- 1234</strong><br/>
</div><!-- END.SingleLinkNoTx -->


约翰·多伊,工商管理硕士

您的第二个xpath不会返回任何内容,因为

是自动关闭的,没有任何内容。相关:下面的同级
运算符可能有用。
<div class="SingleLinkNoTx">
<a href="#10" class="loc-link">Acme Software</a><br/><strong>John Doe, MBA</strong>  <br/>123 Main St.<br />New York, NY 10036<br /><strong class="telephone">(212) 555- 1234</strong><br/>
</div><!-- END.SingleLinkNoTx -->