Skip to content

Instantly share code, notes, and snippets.

@ubiratanbraga
Created March 13, 2015 20:38
Show Gist options
  • Save ubiratanbraga/3a3330fd2900fcb1549d to your computer and use it in GitHub Desktop.
Save ubiratanbraga/3a3330fd2900fcb1549d to your computer and use it in GitHub Desktop.

Revisions

  1. ubiratanbraga created this gist Mar 13, 2015.
    8 changes: 8 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    function fileToDOMDoc($filename) {
    $dom= new DOMDocument;
    $xmldata = file_get_contents($filename);
    $xmldata = str_replace("&", "&", $xmldata); // disguise &s going IN to loadXML()
    $dom->substituteEntities = true; // collapse &s going OUT to transformToXML()
    $dom->loadXML($xmldata);
    return $dom;
    }