Reputation: 59
In my document type declaration, I have the following:
<!ELEMENT all:Test (div)>
<!ATTLIST all:Test
xmlns:all CDATA #FIXED 'http://www.mrinitialman.com/'
xmlns CDATA #FIXED 'http://www.w3.org/1999/xhtml'
xmlns:fnc CDATA #FIXED 'http://www.mrinitialman.com/Functions/'
>
<!ELEMENT div (#PCDATA|fnc:Reference)*>
<!ELEMENT fnc:Reference EMPTY>
The file test.xml
looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE all:Test SYSTEM "./mrinitialman.dtd">
<all:Test xmlns:all="http://www.mrinitialman.com/" xmlns="http://www.w3.org/1999/xhtml"
xmlns:fnc="http://www.mrinitialman.com/Functions/">
<div>Testing 123</div>
</all:Test>
My PHP in a test document looks like this:
<?php
header('Content-Type: text/plain');
$doc = new DOMDocument('1.0','utf-8');
$doc->loadXML(file_get_contents('./test.xml');
echo $doc->saveXML();
?>
My output looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE all:Test SYSTEM "./mrinitialman.dtd">
<all:Test xmlns:all="http://www.mrinitialman.com/" xmlns="http://www.w3.org/1999/xhtml"
xmlns:fnc="http://www.mrinitialman.com/Functions/">
<div xmlns:fnc="http://www.mrinitialman.com/Functions/">Testing 123</div>
</all:Test>
Why is xmlns:fnc="http://www.mrinitialman.com/Functions/"
being repeated in the <div>
start tag? Is there a workaround to this, or just an inherent part of PHP working with XML namespaces?
Upvotes: 1
Views: 27