is it possible to script a .XML file?
是否可以编写.XML文件?
what we are after is there will be a .XML file on a webserver (IIS) for e.g. www.myserver.com/update.xml
我们所追求的是网络服务器(IIS)上将有一个.XML文件,例如: 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
当调用.XML文件时,它将执行一系列调用示例,使数据库跳转,然后以.XML格式返回结果
is this possible?
这可能吗?
3 个解决方案
#1
XML is a data representation and not a scripting language.
XML是一种数据表示,而不是脚本语言。
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.
听起来像你真的想要将URL /update.xml映射到底层脚本/程序(用任何可执行语言),运行然后将数据作为XML类型返回(mime type text / xml)。这是完全可行的。
#2
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
为什么要把它称为.xml?如果您有一个扩展名为.aspx的asp.net页面(因此它将运行),那么您可以在其响应中返回XML并将其内容类型设置为text / xml
Nothing to say an xml file has to have a .xml extention :)
没有什么可说的xml文件必须有.xml扩展名:)
Other web languages are available it could easily be a PHP file, Ruby, JSP etc.
其他Web语言可用,它可以很容易地成为PHP文件,Ruby,JSP等。
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.
此外,您还可以设置IIS(或Apache)将所有.xml扩展文件视为aspx文件,但我会建议不要使用它以便于维护。
#3
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:
绝对没有办法执行XML文件:它只是标记,仅此而已。但是,您可以提出一个可以执行此XML的解释器,但使用XML作为编程语言通常是一个非常糟糕的主意:
<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.
您可以使用任何服务器端脚本技术(PHP,Ruby on Rails,ASP.NET等)实现您所遵循的行为:您只需将Update.xml映射到适当的处理程序,然后它将执行您需要的所有操作。
#1
XML is a data representation and not a scripting language.
XML是一种数据表示,而不是脚本语言。
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.
听起来像你真的想要将URL /update.xml映射到底层脚本/程序(用任何可执行语言),运行然后将数据作为XML类型返回(mime type text / xml)。这是完全可行的。
#2
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
为什么要把它称为.xml?如果您有一个扩展名为.aspx的asp.net页面(因此它将运行),那么您可以在其响应中返回XML并将其内容类型设置为text / xml
Nothing to say an xml file has to have a .xml extention :)
没有什么可说的xml文件必须有.xml扩展名:)
Other web languages are available it could easily be a PHP file, Ruby, JSP etc.
其他Web语言可用,它可以很容易地成为PHP文件,Ruby,JSP等。
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.
此外,您还可以设置IIS(或Apache)将所有.xml扩展文件视为aspx文件,但我会建议不要使用它以便于维护。
#3
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:
绝对没有办法执行XML文件:它只是标记,仅此而已。但是,您可以提出一个可以执行此XML的解释器,但使用XML作为编程语言通常是一个非常糟糕的主意:
<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.
您可以使用任何服务器端脚本技术(PHP,Ruby on Rails,ASP.NET等)实现您所遵循的行为:您只需将Update.xml映射到适当的处理程序,然后它将执行您需要的所有操作。