1
我正在使用php Querypath,我試圖從html字符串中刪除所有html標籤上面和下面的空標籤。例如:使用php querypath刪除html字符串頂部和底部的空標籤
<div> </div>
<div> </div>
<div>I want remove empty div tag on top and bottom</div>
<div> </div>
<div>other content</div>
<div> </div>
<div> </div>
用PHP的QueryPath我想改變成:
<div>I want remove empty div tag on top and bottom</div>
<div> </div>
<div>other content</div>
我該怎麼辦?
所以你想保留一個' '在中間。然後你嘗試使用PHP DOM,http://php.net/manual/en/book.dom.php –