PHP で解析する次の HTML の例があり、「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 »</a>
</div>
</div>
</div>
この PHP コード フラグメント:
//a[@class="loc-link"]//text()
「a href」タグを解析するためのハンドルですが、「br」はどうですか? 私はこれを試しました:
//br[@class="loc-link"]//text()
しかし、これは出力を返しません。
以下を解析して、タグHTML
間のデータ (会社名、所有者、番地、都市、州、郵便番号) を抽出するにはどうすればよいですか?<br />
<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 -->