|
Posted by Treefrog on 04/24/06 17:06
Dino wrote:
> dear all,
>
> i got this script form a customer. in general, it recieves data which is send
> via http to a server and generates a .xml file from this data.
>
> because i'm not familar with .asp, i'm totally lost transferring this script
> to php. i don't understand which way the data is recieved and how it's saved.
>
> ---------- [SCRIPT START] -----------
>
> <%
> dim objXML
> dim lngRet
// declaring vars, ignore, you don't need to in PHP, although you
perhaps should.
>
> set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
// ignore, this is creating an object which isn't available in PHP.
Perhaps use simpleXML
> on error resume next
>
> ' set basic XML parser settings
> objXML.Async = False
> ' optional beide Werte auf true
> objXML.ValidateOnParse = False
> objXML.resolveExternals = False
>
> Response.Expires = -1000
// ignore all of the above.
>
> ' V3.0(+) of XML parser allows loading of the Request object
> lngRet = objXML.Load(Request)
// build an XML object based on the request data... see below for my
comments about that
> if lngRet = True then
> call objXML.Save(Server.MapPath("LastReceivedDocument.xml"))
>
> response.write "<cXML><Response>" & _
> "<Status code=" & chr(34) & "200" & chr(34) & " text=" &
> chr(34) & "OK" & chr(34) & "/>" & _
> "</Response>" & _
> "</cXML>"
> else
> response.write "<cXML><Response><Status code='404' text='Error loading
> XML'></Status></Response></cXML>"
> end if
// above should be obvious.
>
> set objXML = nothing
// tidy up memory.
> %>
>
> ---------- [SCRIPT END] -----------
Before I reply, I want to say I've never coded ASP in my life before,
so I can't see why you wouldn't be able to figure it out, but
nevertheless....
The code seems to be serializing the request object, then returning a
little bit of XML to the browser, depending on the sucess of the
request object save operation.
Now, I'm not sure how you can do this in PHP quickly, but if you don't
need the saved files to be XML, you could use serialize($_REQUEST).
Otherwise I think you will have to loop through the request elements
and build the XML yourself, then save the file and return the relevant
XML depending on it's sucess.
Look at the code above, I've added some comments that might help you.
Navigation:
[Reply to this message]
|