Jump to content

Help...php Code Missing In Tutorial


CarpeDiem

Recommended Posts

In the excellent w3schools tutorial XSLT - Editing XML, this particular chapter ends showing how to complete the editing of this cross-browser solution with ASP, but unlike most all other tutorials, this one does not offer a PHP equivalent from which PHP students can learn.Since my site is with Linux-based HostMonster & they only list PHP software for SQL and other functions (and no ASP), and since I learned in the tutorials that PHP can do everything that ASP can do, and also since ASP classic is being deprecated in favor of ASP.net, I only studied PHP, since I seem to have no functional use at the moment for ASP knowledge with my host or for my site.I simply cannot understand the sequence of ASP code in this tutorial myself in order to either learn from it or to translate it into PHP. I know there's a lot of lines in the ASP code, but how does a PHP coder do all these functions in PHP instead? There's just no PHP guidance as of this date within the tutorial, so here I am! If I can see a fully working PHP equivalent, I think I can learn and carry on. This is a nifty cross-browser solution!Here's the ASP code direct from the w3schools tutorial (Note: The other required files which work together with the following ASP code are at this tutorial link):

<%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%>

Does anybody know how to fully (well, functionally) pull the above ASP code off in PHP so that it would work with the other files in this tutorial in a real-world application?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...