我想用PHP解析DocBook XML文件。 SimpleXMLElement会切断一些标记元素。
<section>
<title>SUSPEND</title>
<para>The <database>SUSPEND</database> command <quote>breaks</quote> the atomicity of the block in which it is located.</para>
<para>...</para>
</section>
我使用此代码来解析我的para元素:
$paras = $xml->xpath("//*[starts-with(local-name(), 'para')]");
foreach($paras as $para) {
echo $para[0];
}
这会切断我的标记
<database>SUSPEND</database> and <quote>breaks</quote>
导致
The command the atomicity of the block in which it is located.
但我需要的是:
The <database>SUSPEND</database> command <quote>breaks</quote> the atomicity of the block in which it is located.
那么如何将整个节点包含其元素作为字符串?