关于ASP用FSO输出XML文件的问题,请高手指教。

killeyes 2004-08-09 12:08:01
Sub CreateAfile(path,msgstr)
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(path,2)
MyFile.WriteLine(msgstr)
MyFile.Close
End Sub

xmlurlstr="<?xml version='1.0' encoding='UTF-8'?> <vto>"
xmlurlstr=xmlurlstr&"<subject name='中文' url='http://' block='true'/>"
xmlurlstr=xmlurlstr&"<subject name='中文' url='http://' block='true'/>"
xmlurlstr=xmlurlstr&"<subject name='中文' url='http://' block='true'/>"
xmlurlstr=xmlurlstr&"</vto>"

CreateAfile server.mappath("./")&"/menu.xml",replace(xmlurlstr,"'",chr(34))

'////////////////////////////////////////////////////////////////////
CreateTextFile不能输出UTF-8的格式的文件,请问还有什么办法可以解决?
谢谢。
...全文
240 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2004-08-18
  • 打赏
  • 举报
回复
斜线的转义问题?
超级大笨狼 2004-08-14
  • 打赏
  • 举报
回复
dom.save应该可以解决的。
超级大笨狼 2004-08-14
  • 打赏
  • 举报
回复
用save

靠,死狐狸你跑出来帮什么腔。。。
  • 打赏
  • 举报
回复
哼,大狼,狐狸哥帮我,呵呵*^_^*
nchen123 2004-08-14
  • 打赏
  • 举报
回复
哦,我说句话都不行么?
nchen123 2004-08-13
  • 打赏
  • 举报
回复
兔子水平不错
  • 打赏
  • 举报
回复
来翻译一下
千万别使用CreateObject

Server.Createobject和CreateObject到底有啥区别呢?看起来,两者换着使应该问题不大,但实际上如果你使用错了的话,会使你的ASP程序出大问题.

VBS里的CreateObject是在脚本引擎的上下文环境里创建的对象实例,而不是在当前正在执行的ASP页面的上下文环境里.在单机的时候,这个方法没有什么问题,但是在一个web server上,它不仅阻止了对asp页面内部属性和值的访问,而且还没有使用Server.CreateObject时所能拥有的内存管理和进程独立功能

当使用asp页面时,我们实际上还未发现CreateObject对于Server.CreateObject的任何很明显的优点.所以,请务必在您要使用createobject的时候使用server.createobject
孟老大什么都好,就是爱引用MSDN上的东东,呵呵,乖乖,经常给他做翻译工作,累啊,我现在也看MSDN的东东了,不过还是买了很多中文书,惨
  • 打赏
  • 举报
回复
Never Use CreateObject
--------------------------------------------------------------------------------
What's the difference between CreateObject and Server.CreateObject? They seem like they should be interchangable, but using the wrong one can cause your ASP application to fall flat on it's face.

VBScript's CreateObject method creates instances of objects inside the scripting engine's context and not in the context of the currently executing ASP page. This works fine in a single user environment, but on a web server it not only prevents the object from gaining access to the ASP intrinsics or the values from the current page, it also bypasses the memory management and process isolation benefits you get automatically when you use Server.CreateObject.

When working with ASP files, we've yet to find any benefit (or any reason at all) to use VBScipt's CreateObject over the one available from the Server object. So make sure that every time you use CreateObject you use Server.CreateObject.


---------------------------------------------------------------

Understanding IIS/MTS Integration
=================================================

A number of performance problems in COM/ASP applications can be traced to a lack of understanding of the IIS/MTSintegration model. The ASP and IIS newsgroups are plagued with questions like "What is the difference between Server.CreateObject, CreateObject,and <OBJECT>?" and "What benefits can I reap by using the @TRANSACTION directive in an ASP page?" The Active Server Pages runtime was originally engineered as an in-process server loaded into the process space ofInternet Information Server (inetinfo.exe). Prior to MTS, COM developers deploying server-side components sometimes used inetinfo.exe as a surrogate process. This led to numerous performance problems and a lack of fault tolerance in web applications. When IIS 4.0 was introduced, it promised fault tolerance by allowing ASP to run in its own isolated process. In order to make this possible, an additional layer of abstraction was placed on top of ASP. This layer, which is implemented as a COM object running inside MTS is known as a Web Application Manager (WAM) component. A common paradigm found in COM and MTS is the introduction of a level of indirection as an instrument of functionality. Other examples of this use of indirection are the concept of interception in MTS and the use of class objects in classical COM. The WAM component provides a level of indirection that shields ASP developers from the internal gears of MTS. When an ASP application is created, the system simultaneously creates a WAM component, which is initially registered in MTS as a library package, meaning that it will be packaged as a .DLL rather than a separate process. Under this scenario, running the ASP application allows the ASP intrinsic objects (Request, Response, etc.) to be created in the same process as IIS. Fault tolerance can be introduced simply by changing the "Run in separate process" attribute in the properties page of the desired web application. It is important to note at this point that WAM components do not actually execute ASP code. Instead, each WAM component relies on the assistance of a Page object. It is the Page object, which acts as an abstraction to the physical ASP page, which is responsible for executing server-side code in the MTS environment. With the release of MTS, Microsoft introduced a new concurrency model known as the activity, which satisfies the ACID transaction requirements. An activity represents a group of objects created on behalf of a single base client. In a client/server application this concept is easy to grasp. A forms-based MFC or Visual Basic front-end calls objects residing in MTS packages in another process. When an Active Server Page, and hence the Page object, becomes the client, things get a little more confusing. A direct benefit of the IIS/MTS integration model is the fact that a Page object can act as the root object of a transaction. In order to accomplish this, simply place an ASP directive with the transaction attribute at the top of the ASP page, for example:

<% @TRANSACTION=Required %>

When an ASP page is requested that contains this attribute, the Page object will serve as the root of the transaction and thus control its ultimate outcome. Understanding this basic architecture can answer such simple questions as the common "What is the difference between Server.CreateObject and CreateObject?" Because the Page object in an ASP page acts as the root of an activity in MTS, a call to Server.CreateObject is analogous to ObjectContext.CreateInstance. In addition, this call marshals the ASP intrinsic objects to MTS. Calling CreateObject API directly will ignore the context that the page is running in and will result in the creation of an additional activity. In other words, CreateObject will result in a call to CoCreateInstance rather than a call to ObjectContext.CreateInstance.

This causes the following problems:

1. ASP will be unaware of the objects created.

2. The deprecated OnStartPage/OnEndPage methods will not be called.

3. ASP will be unaware of the threading model of the created objects.

So should you use transactional pages? There is obviously no single answer to that question. It depends on your application architecture and what you are trying to accomplish. However, keep these tips in mind when using transactional pages:

1. Transaction control is much greater when using a classical COM component.

2. Active Server Pages are still considered part of the presentation layer in an n-tier application, and assuch, all business logic should reside in COM components.
  • 打赏
  • 举报
回复
呵呵,在单机的时候,CreateObject("Scripting.FileSystemObject")跟Set fso = server. CreateObject("Scripting.FileSystemObject")是一样的,给你帖一篇to be continue
超级大笨狼 2004-08-13
  • 打赏
  • 举报
回复
Set fso = CreateObject("Scripting.FileSystemObject")


====>

Set fso = server. CreateObject("Scripting.FileSystemObject")
binghgo 2004-08-10
  • 打赏
  • 举报
回复
mark
adamxx 2004-08-10
  • 打赏
  • 举报
回复
关注!
duoduobaba 2004-08-09
  • 打赏
  • 举报
回复
学习
killeyes 2004-08-09
  • 打赏
  • 举报
回复
:(
killeyes 2004-08-09
  • 打赏
  • 举报
回复
我顶一下,有知道的帮个忙,谢谢。
killeyes 2004-08-09
  • 打赏
  • 举报
回复
文本内容中发现无效字符。处理资源 'file:///G:/web/work/vto/menu.xml'

我无语。有高手可以帮帮吗?

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧