How to do this XML-XSLT in PHP? [closed]

I'm trying to learn webdesign and -again- am stuck in something, can anyone help me with this code?It is in ASP but I am learning PHP... Here is the original page w3schools XSLT Editing XML The ASP File.The HTML form in the \[code\]tool.xsl\[/code\] file above has an action attribute with a value of \[code\]edittool.asp\[/code\]. The \[code\]edittool.asp\[/code\] page contains two functions: The \[code\]loadFile()\[/code\] function loads and transforms the XML file for display and the \[code\]updateFile()\[/code\] function applies the changes to the XML file: \[code\]<%function loadFile(xmlfile,xslfile)Dim xmlDoc,xslDoc'Load XML fileset xmlDoc = Server.CreateObject("Microsoft.XMLDOM")xmlDoc.async = falsexmlDoc.load(xmlfile)'Load XSL fileset xslDoc = Server.CreateObject("Microsoft.XMLDOM")xslDoc.async = falsexslDoc.load(xslfile)'Transform fileResponse.Write(xmlDoc.transformNode(xslDoc))end functionfunction updateFile(xmlfile)Dim xmlDoc,rootEl,fDim i'Load XML fileset xmlDoc = Server.CreateObject("Microsoft.XMLDOM")xmlDoc.async = falsexmlDoc.load(xmlfile)'Set the rootEl variable equal to the root elementSet rootEl = xmlDoc.documentElement'Loop through the form collectionfor i = 1 To Request.Form.Count 'Eliminate button elements in the form if instr(1,Request.Form.Key(i),"btn_")=0 then 'The selectSingleNode method queries the XML file for a single node 'that matches a query. This query requests the value element that is 'the child of a field element that has an id attribute which matches 'the current key value in the Form Collection. When there is a match - 'set the text property equal to the value of the current field in the 'Form Collection. set f = rootEl.selectSingleNode("field[@id='" & _ Request.Form.Key(i) & "']/value") f.Text = Request.Form(i) end ifnext'Save the modified XML filexmlDoc.save xmlfile'Release all object referencesset xmlDoc=nothingset rootEl=nothingset f=nothing'Load the modified XML file with a style sheet that'allows the client to see the edited informationloadFile xmlfile,server.MapPath("tool_updated.xsl")end function'If the form has been submitted update the'XML file and display result - if not,'transform the XML file for editingif Request.Form("btn_sub")="" then loadFile server.MapPath("tool.xml"),server.MapPath("tool.xsl")else updateFile server.MapPath("tool.xml")end if%>\[/code\]
 
Back
Top