)获取整个节点
我想用php解析docbook xml文件。Simplexmlelemt切断了一些标记元素。
<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.
那么,如何将整个节点(包括字符串)(
只需使用asxml方法在element
的root上获取树foreach($paras as $para) {
echo $para->asXML();
}