我有一个 xml 文档(从 msword 2010 生成),我正在尝试使用简单的 xml 进行处理。
xml 示例:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
<w:body>
<w:p w:rsidR="005B1098" w:rsidRDefault="005B1098"/>
<w:p w:rsidR="00F254A4" w:rsidRDefault="00F254A4"/>
<w:p w:rsidR="00F254A4" w:rsidRPr="008475A1" w:rsidRDefault="00C15492" w:rsidP="008475A1">
<w:pPr>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:sz w:val="44"/>
<w:szCs w:val="44"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="008475A1">
<w:rPr>
<w:b/>
<w:sz w:val="44"/>
<w:szCs w:val="44"/>
</w:rPr>
<w:t>Test file</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00C15492" w:rsidRPr="008475A1" w:rsidRDefault="00C15492" w:rsidP="008475A1">
<w:pPr>
<w:jc w:val="center"/>
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="008475A1">
<w:rPr>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
<w:t>another paragraph</w:t>
</w:r>
</w:p>
</w:body>
</w:document>
我正在尝试使用以下方法打开它:
$content = '/reports/docx_templates/testing2.xml';
if(!$simple_xml = simplexml_load_file($content)){
trigger_error('Error reading XML file',E_USER_ERROR);
} else {
echo 'loaded';
}
并得到错误:
Message: simplexml_load_file(): I/O warning : failed to load external entity " Test file another paragraph "
有任何想法吗?