开发者

XmlTextWriter not working in my VB .ASP page Literal

I'm getting the error below when I try usign the XmlTextWriter in my VB aspx page

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30002: Type 'XmlTextWriter' is not defined.

The code I'm using is within the .aspx page inside a <% %> literal

Dim w As XmlTextWriter = New XmlTextWriter("myxmlfile.xml")

My page header is also like this

<%@ Page Language="vb" AutoEventWireup="false" Trace="True" EnableViewStat开发者_开发知识库e="True" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Xml" %>

Can anybody explain why?


As mentioned in the MSDN, the XmlTextWriter class is defined in the System.Xml namespace:

XmlTextWriter

So, you should add the

Imports System.Xml

directive to the head of the code behind file and also make certain that the System.xml.dll is referenced by your web application.


XmlTextWriter actually takes two values, try this...

<%@ Page Language="vb" AutoEventWireup="false" Trace="True" EnableViewState="True" %> 
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<% Dim w As New XmlTextWriter("myxmlfile.xml", System.Text.Encoding.ASCII)%>

If that doesn't work, perhaps you have a global XML namespace that is overriting the System.XML class, in which case try

<%@ Page Language="vb" AutoEventWireup="false" Trace="True" EnableViewState="True" %> 
<% Dim w As New System.Xml.XmlTextWriter("myxmlfile.xml", System.Text.Encoding.ASCII)%>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜