1
及彼td標籤之間的內容是樣本數據使用正則表達式
<table class="sparql" border="1">
<tr> <th>abstract</th></tr>
<tr>
<td>
Cologne is Germany's fourth-largest city, and is the
largest city both in
the German Federal State of North Rhine-Westphalia and within the
Rhine-Ruhr Metropolitan Area, one of the major European metropolitan
areas with more than ten million inhabitants."@en
</td>
</tr>
</table>
,我試圖讓使用正則表達式<td>
標籤之間的內容。我試過類似
<td>.*</td>
但是如何丟棄tags
itselef?
使用組別'(。*)'然後取第一個。 – 2012-03-20 15:59:36
正則表達式(通常)不應該用於解析HTML。更好的方法是使用TagSoup將HTML解析爲有效的XML文檔,然後使用CF的XML函數提取所需的數據。 Ben Nadel最近在CF10上做了這個帖子,但我沒有看到有什麼理由不能在舊版本中使用它 - 你只需要自己抓住TagSoup庫,因爲它並沒有預先安裝到CF10 。他的博客文章在這裏:http://www.bennadel.com/blog/2341-ColdFusion-10-Parsing-Dirty-HTML-Into-Valid-XML-Documents.htm – 2012-03-20 17:48:23