使用ASP.NET生成XML而不是HTML [英] Using ASP.NET to generate XML instead of HTML

查看:73
本文介绍了使用ASP.NET生成XML而不是HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在研究一个项目,我们使用ASP.NET生成动态XML(实际上是VoiceXML)而不是HTML.它可以工作,但是Visual Studio会引发很多XHTML验证错误(因为它希望在.aspx页中看到HTML而不是XML).

示例.在我的Test.aspx页面中,我有类似以下的代码:

<% @ 页面 语言 =""C#" AutoEventWireup <字体颜色=#0000ff" size = 2> =真" CodeFile = " Test.aspx.cs" 继承 ="Test" %>

<? xml 版本 ="1.0" 编码 =""UTF-8" ?>
<
vxml xmlns =""http://www.w3.org/2001/vx ml" 版本 ="2.1" xmlns : xsi = http://www.w3.org/2001/XMLSchema-instance xsi : schemalocation =&; http://www.w3.org/2001/vxml form id ="BeverageForm">
< 提示 >
现在日期是<% = GetCurrDate()%>
</ 提示 >
</ 表格 >
</
vxml <字体color =#0000ff" size = 2>>

Hi,
 
I am working on a project where we use ASP.NET to generate dynamic XML (actually VoiceXML) instead of HTML. It works, but Visual Studio thows a lot of XHTML validation errors (because it expects to see HTML instead of XML in the .aspx page).

Example. In my Test.aspx page, I have code like the following:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>

<?xml version="1.0" encoding="UTF-8" ?>
<
vxml xmlns="http://www.w3.org/2001/vxml" version="2.1" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemalocation="http://www.w3.org/2001/vxml http://www.w3.org/TR/2007/REC-voicexml21-20070619/vxml.xsd">
<
form id="BeverageForm">
<prompt>
            The Date is now <%= GetCurrDate()%>
</prompt>
</form>
</
vxml>

受保护的 无效 Page_Load( 对象 发送者, EventArgs <字体大小= 2> e)
{
Response.ContentType =
"text/xml" ;
}

protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType =
"text/xml";
}

公共 字符串 GetCurrDate()
{
返回 DateTime .Now.ToLongDateString();
}

public string GetCurrDate()
{
return DateTime.Now.ToLongDateString();
}

推荐答案

我找到了一种在Visual Studio中关闭XHTM错误的方法.工具->选项-> HTML->验证->取消选中显示错误"盒子.但是,我仍然很想知道是否有一种方法可以使Visual Studio使用自定义XSD架构来验证.aspx页中的XML.我知道在Visual Studio中构建静态XML时可以做到这一点.
I found one way to turn off XHTM errors in Visual Studio. Tools->Options->HTML->Validation->Uncheck the "Show Errors" box. However, I am still interested to find out if there is a way to make Visual Studio use a custom XSD schema to validate the XML in the .aspx page. I know this can be done when we are building static XML in Visual Studio.


这篇关于使用ASP.NET生成XML而不是HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆