你好我有这些孤立的html代码(作为我的输入):
情况1:
<td class="C" width="10%">
<a href="URL1" onclick="ValDobleSubmit()">
String1
<span style="color: blue; font-weight:bold;">
String2
</span>
</a>
</td>
<td class="C" width="15%">
String3
</td>
<td class="t" align="left" width="15%">
String4
</td>
<td class="t" align="left" width="10%">
String5
</td>
案例2
<td class="C" width="10%">
<a href="URL1" onclick="ValDobleSubmit()">
String1
</a>
</td>
<td class="C" width="15%">
String3
</td>
<td class="t" align="left" width="15%">
String4
</td>
<td class="t" align="left" width="10%">
String5
</td>
我想使用bash shell脚本或PHP(控制台)来获得此输出:
String1String2 | URL1 | STRING3 |串,4 | STRING5
字符串1 | URL1 | STRING3 |串,4 | STRING5
答案 0 :(得分:0)
$DOM = new DOMDocument;
$DOM->loadHTML($CaseSource);
$cells = $DOM->getElementsByTagName('td');
foreach($cells as $cell){
$out[] = $cell->nodeValue;
}