views:

63

answers:

3

Hi,

is it possible to script a .XML file?

what we are after is there will be a .XML file on a webserver (IIS) for e.g. www.myserver.com/update.xml

which when called should execute it as a script rather than serve it as a file.

when the .XML file is called it will excute a series of calls example make a DB trip and then return the result in .XML format

is this possible?

+3  A: 

XML is a data representation and not a scripting language.

It sounds to me like you actually want to map the URL /update.xml to an underlying script/program (in any executable language), have that run and then return the data as an XML type (mime type text/xml). Which is perfectly feasible.

Brian Agnew
+1  A: 

why call it .xml at all? If you have a asp.net page with an extention of .aspx (so it will run) then you can have that return XML in its response and set its content type to be text/xml

Nothing to say an xml file has to have a .xml extention :)

Other web languages are available it could easily be a PHP file, Ruby, JSP etc.

Additionally you could also set up IIS (or Apache) to treat all .xml extention files as aspx files though I would advise against it for ease of maintenance.

Pete Duncanson
Some web analytics software will report it as being a page hit if it has the extension of a normal page. Not always relevant but that should always be kept in mind.
smack0007
Why call it .xml at all? Because a Web resource must be named by the result it produces, not by the technology it uses. Except you, noone cares that your Web programs are in PHP or ASP. But users can be interested by the fact that the result is PNG or XML or CSV.
bortzmeyer
A: 

There's absolutely no way an XML file can be executed: it's just markup, nothing more. However, you can come up with an interpreter which would execute this XML, but using XML as a programming language is generally a very bad idea:

<if condition="a = 5">        
    <invoke function="doStuff">
        <parameter value="34" />
    </invoke>
</if>

The behavior you're after can be achieved with any server-side scripting technology (PHP, Ruby on Rails, ASP.NET, etc.): you just map the Update.xml to an appropriate handler and it will then do everything you need.

Anton Gogolev