我是simplexml parserPHP的新手.我已经运行了我找到的示例,它们的工作方式与广告一致.我不能让它与我的程序一起工作.我在这里搜索了几个小时.
我有一个名为core.xml的XML文件(注意节点标签有冒号):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dc:title>Lecture 3</dc:title>
<dc:creator>John Brown & Greg Smith</dc:creator>
<cp:lastModifiedBy>Greg Smith</cp:lastModifiedBy>
<cp:revision>165</cp:revision>
<dcterms:created xsi:type="dcterms:W3CDTF">2010-02-19T04:37:55Z</dcterms:created>
<dcterms:modified xsi:type="dcterms:W3CDTF">2014-01-30T02:41:30Z</dcterms:modified>
</cp:coreProperties>
Run Code Online (Sandbox Code Playgroud)
我使用以下代码将其加载到解析器中:
if (file_exists('core.xml')){
echo 'file exists <br>';
$xml_core = simplexml_load_file('core.xml');
print_r($xml_core);
}
else
{
exit('Failed to open core.xml.');
}
Run Code Online (Sandbox Code Playgroud)
该文件存在,但我在print_r得到的是:
file exists
SimpleXMLElement Object ( )
Run Code Online (Sandbox Code Playgroud)
我如何访问节点?我必须使用的其他XML文件有很多层.
谢谢