title: PHP/XML - Problem with default namespaces when append fragment
body: <p>I have the original file and I want to append fragment in security tag.</p>
  <pre><code>&lt;!-- Original File --&gt;
  &lt;example&gt;
      &lt;header&gt;
          &lt;facticeA&gt;123&lt;/facticeA&gt;
          &lt;facticeB&gt;456&lt;/facticeB&gt;
      &lt;/header&gt;
      &lt;body&gt;
          &lt;facticeC&gt;789&lt;/facticeC&gt;
      &lt;/body&gt;
      &lt;security&gt;&lt;/security&gt;
  &lt;/example&gt;
  &lt;!-- ------------ --&gt;
  </code></pre>
  <pre><code>&lt;!-- Original Fragment --&gt;
  &lt;saml2:Assertion xmlns:saml2=&quot;urn:oasis:names:tc:SAML:2.0:assertion&quot; ID=&quot;_eb0b47cc-d4b0-44ba-a08c-90047e3a8b03&quot; IssueInstant=&quot;2022-07-18T14:08:46.138Z&quot; Version=&quot;2.0&quot;&gt;
      &lt;saml2:Issuer&gt;&lt;/saml2:Issuer&gt;
      &lt;Signature xmlns=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;XXXXXXXX&lt;/Signature&gt;
  &lt;/saml2:Assertion&gt;
  &lt;!-- ----------------- --&gt;
  </code></pre>
  <p>I use &quot;<strong>createDocumentFragment()</strong>&quot; and &quot;<strong>appendXml()</strong>&quot; PHP functions
  And I have this result.</p>
  <pre><code>&lt;!-- Final File --&gt;
  &lt;example&gt;
      &lt;header&gt;
          &lt;facticeA&gt;123&lt;/facticeA&gt;
          &lt;facticeB&gt;456&lt;/facticeB&gt;
      &lt;/header&gt;
      &lt;body&gt;
          &lt;facticeC&gt;789&lt;/facticeC&gt;
      &lt;/body&gt;
      &lt;security&gt;
          &lt;saml2:Assertion xmlns:saml2=&quot;urn:oasis:names:tc:SAML:2.0:assertion&quot; xmlns:default=&quot;http://www.w3.org/2000/09/xmldsig#&quot; ID=&quot;_eb0b47cc-d4b0-44ba-a08c-90047e3a8b03&quot; IssueInstant=&quot;2022-07-18T14:08:46.138Z&quot; Version=&quot;2.0&quot;&gt;
              &lt;saml2:Issuer/&gt;
              &lt;default:Signature xmlns=&quot;http://www.w3.org/2000/09/xmldsig#&quot;&gt;XXXXXXXX&lt;/default:Signature&gt;
          &lt;/saml2:Assertion&gt;
      &lt;/security&gt;
  &lt;/example&gt;
  &lt;!-- ---------- --&gt;
  </code></pre>
  <p>The inserted fragment is not the same than original fragment.
  &quot;<strong>Signature</strong>&quot; tag become &quot;<strong>default:Signature</strong>&quot; tag. And the namespace &quot;xmldsig&quot; present in Signature tag is append to Assertion tag with word &quot;<strong>default</strong>&quot;</p>
  <p>If I delete namespace &quot;xmldsig&quot; in the Signature tag I have no problem.
  The inserted fragment is the same than original fragment.</p>