XSLT edit XML with PHP (need help!)

So I was finally able to find what I wanted to online today but the process is in ASP http://www.w3schools.com/Xsl/xsl_editxml.asp.

I want to be able to do that but in php. I already have my xml and xsl files ready to go but I cannot for the life of my figure out how to edit the forms and update the xml.

I was able to read the xml file and output it using some DOM functions but I can’t seem to figure out how to edit multiple random fields and save them using php. Any ideas?

Here is what I have:

            $rfile = $eid;
            $freader = fopen($rfile, 'r') or die("Can't open read file");
            $theData = fread($freader, filesize($rfile));
            // Load XML file
            $XML = new DOMDocument();
            $XML->loadXML( $theData );
            // Start xslt
            $xslt = new XSLTProcessor();
            $XSL = new DOMDocument();
            $XSL->load( $XSLpath, LIBXML_NOCDATA);
            $xslt->importStylesheet( $XSL );
            // Print 
            print $xslt->transformToXML( $XML );