在我的代碼,我有上一層> saveHTML()方法轉換 空間
$document = DomDocument->loadHTML($someHTML);
$xPath = new DOMXPath($document);
//
//do some xpath query and processing
//
$result = $document->saveHTML();
我處理包含 的HTML:
<html>
<body>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-autospace:none"><b><span style='font-size:9.0pt;font-family:"ArialNarrow","sans-serif";
color:red'> </span></b></p>
</body>
</html>
和結果:
<html>
<body>
<p class="MsoNormal" style="margin-bottom:0in;margin-bottom:.0001pt;line-height:
normal;text-autospace:none"><b><span style='font-size:9.0pt;font-family:"ArialNarrow","sans-serif";
color:red'> </span></b></p>
</body>
</html>
如何防止
轉換爲空白?
你在做什麼樣的xpath和處理,實體被刪除?你使用正常化的空間還是類似的東西? – hakre 2012-05-30 13:36:54
可能相關:[PHP的DOMNode實體和nodeValue](http://stackoverflow.com/questions/2752434/php-domnode-entities-and-nodevalue) – hakre 2012-06-12 11:31:28
謝謝,我會嘗試這個選項 – ltfishie 2012-06-12 17:44:12