douchan4674
2016-08-09 07:46
浏览 44

PHP - 在DOMDocument中包含DOMDocumentFragment和未定义的命名空间

MasetrPage.xml:

<?xml version="1.0" encoding="UTF-8"?>
<PAGE
xmlns:PHOENIX = 'PHOENIX'
xmlns:PHOENIX.CORE = 'PHOENIX/CORE'
xmlns:PHOENIX.CORE.PAGE = 'PHOENIX/CORE/PAGE'
xmlns:PHOENIX.CORE.COMPILER = 'PHOENIX/CORE/COMPILER'
>
</PAGE>

Page.xml:

<PHEONIX.CORE:EXAMPLE.ELEMENT />
<PHEONIX.CORE:EXAMPLE.ELEMENT2 />

Now I want to include the Page.xml content inside the MasterPage.xml PAGE tag.

My PHP Code:

//[i] Initialize new \DOMDocument from from PageMaster.xml.
$pageDocument = \DOMDocument::load('PageMaster.xml');

//[i] Create fragment from pageDocument and append content from page XML.
$pageDocument_frag = $pageDocument->createDocumentFragment();
$pageDocument_frag->appendXML(file_get_contents('Page.xml'));

But here I get an error that the namespaces are not defined inside the Page.xml. But for my project I don't want to define the namespaces inside the Page.xml

1条回答 默认 最新

相关推荐 更多相似问题