导 读:介绍了有关ASP.NET中XML控件的使用,有个小BUG:在WEBFORM.ASPX中出现的XML控件,其中的transformsource属性设定了样式表文件路径,可是在文章出处没有找到这个XSL文件.:( 自己解决吧.
--------------------------------------------------------------------------------
在这个代码中揭示了微软在ASP.NET架构中隐藏的一个WEB表单控件,即,我只给代码,不给解释,大家自己下课后去研究吧。
另外,由于是beta1,在这个控件中你使用的xslt里面不能使用,当然,亦不能使用那个order-by了,因为它支持的xsl空间是带"1999"的那个,而不是原来的那个。
另外,我从微软得到的回答就是在beta2里面,它将支持,就可以全部转向xml+xsl了,而不用再为源代码保密问题头疼了。
请看下例:
webform2.cs
-
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Xml;
public class WebForm2 : Page
{
public StringBuilder outputQ;
public StringBuilder outputXml;
public DocumentNavigator nav = null;
public HtmlInputFile XmlFile;
public System.Web.UI.WebControls.Xml MyXml;
public System.Web.UI.WebControls.TextBox TextBox1;
public System.Web.UI.WebControls.TextBox TextBox2;
public System.Web.UI.WebControls.TextBox TextBox3;
public System.Web.UI.WebControls.Button Query;
public System.Web.UI.WebControls.Label FileLabel;
public void On_KeyUp(object sender, System.EventArgs e)
{
Response.Write("Works");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//
// Evals true first time browser hits the page
//
}
}
public void Query_Click(object sender, System.EventArgs e)
{
HttpPostedFile xmlfile = XmlFile.PostedFile;
XmlDocument doc = new XmlDocument();
MyXml.Document = new XmlDocument();
// TextBox2.Text="";
// TextBox3.Text="";
if (xmlfile.FileName != String.Empty)
{
try
{
FileLabel.Text= xmlfile.FileName;
MyXml.Document.Load(xmlfile.FileName);
outputXml = new StringBuilder();
XmlTextReader reader = new XmlTextReader (xmlfile.FileName);
ShowDocument();
TextBox3.Text = outputXml.ToString();
outputQ = new StringBuilder();
doc.Load(xmlfile.FileName);
DocumentNavigator nav = new DocumentNavigator(doc);
// Perform the query e.g. "descendant::book/price"
XPathQuery(nav, TextBox1.Text);
TextBox2.Text = outputQ.ToString();
}
catch (Exception exp) {
//outputQ.Append("
"+ exp.Message+"
");
}
finally {}
}
else if (FileLabel.Text != String.Empty)
{
try
{
MyXml.Document.Load(FileLabel.Text);
outputXml = new StringBuilder();
XmlTextReader reader = new XmlTextReader (FileLabel.Text);
ShowDocument();
TextBox3.Text = outputXml.ToString();
ShowDocument();
outputQ = new StringBuilder();
doc.Load(FileLabel.Text);
DocumentNavigator nav = new DocumentNavigator(doc);
// Perform the query e.g. "descendant::book/price"
XPathQuery(nav, TextBox1.Text);
TextBox2.Text = outputQ.ToString();
}
catch (Exception exp) {
outputQ.Append("
"+ exp.Message+"
");
}
finally {}
}
}
private void XPathQuery(XmlNavigator navigator, String xpathexpr )
{
try
{
// Save context node position
navigator.PushPosition();
navigator.Select (xpathexpr);
FormatXml(navigator);
// Restore context node position
navigator.PopPosition();
}
catch (Exception e)
{
}
}
//***************************** Navigator ************************************
private void FormatXml (XmlNavigator navigator)
{
while (navigator.MoveToNextSelected())
{
switch (navigator.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Format (navigator, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (navigator, "DocumentType");
break;
case XmlNodeType.Document:
Format (navigator, "Document");
break;
case XmlNodeType.Comment:
Format (navigator, "Comment");
break;
case XmlNodeType.Element:
Format (navigator, "Element");
break;
case XmlNodeType.Text:
Format (navigator, "Text");
break;
case XmlNodeType.Whitespace:
Format (navigator, "Whitespace");
break;
}
}
outputQ.Append("rn");
}
// Format the output
private void Format (XmlNavigator navigator, String NodeType)
{
String value = String.Empty;
String name = String.Empty;
if (navigator.HasChildren)
{
name = navigator.Name;
navigator.MoveToFirstChild();
if (navigator.HasValue)
{
value = navigator.Value;
}
}
else
{
if (navigator.HasValue)
{
value = navigator.Value;
name = navigator.Name;
}
}
outputQ.Append(NodeType + "" + value);
outputQ.Append("rn");
}
// ********************************** XmlReader *****************************
public void ShowDocument ()
{
outputXml = new StringBuilder();
XmlTextReader reader = new XmlTextReader (FileLabel.Text);
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.ProcessingInstruction:
Format (reader, "ProcessingInstruction");
break;
case XmlNodeType.DocumentType:
Format (reader, "DocumentType");
break;
case XmlNodeType.Comment:
Format (reader, "Comment");
break;
case XmlNodeType.Element:
Format (reader, "Element");
break;
case XmlNodeType.Text:
Format (reader, "Text");
break;
case XmlNodeType.Whitespace:
break;
}
}
TextBox3.Text = outputXml.ToString();
}
protected void Format(XmlReader reader, String NodeType)
{
// Format the output
for (int i=0; i
{
outputXml.Append(t);
}
outputXml.Append(reader.Prefix + NodeType + "" + reader.Value);
// Display the attributes values for the current node
if (reader.HasAttributes)
{
outputXml.Append(" Attributes:");
for (int j=0; j
{
outputXml.Append(reader[j]);
}
}
outputXml.Append("rn");
}
/// ************************* DOM *********************************
protected void ShowDocument(XmlNode node)
{
if (node != null)
Format (node);
if (node.HasChildNodes)
{
node = node.FirstChild;
while (node != null)
{
ShowDocument(node);
node = node.NextSibling;
}
}
}
// Format the output
private void Format (XmlNode node)
{
if (!node.HasChildNodes)
{
outputXml.Append("t" + "");
}
else
{
outputXml.Append("");
if (XmlNodeType.Element == node.NodeType)
{
XmlNamedNodeMap map = node.Attributes;
foreach (XmlNode attrnode in map)
outputXml.Append(" " + attrnode.Name + " ");
}
outputXml.Append("rn");
}
}
}
下面就是webform2.aspx了
webform2.aspx
---

每年Apple发布新的iOS和macOS大版本之前,用户都可以提前几个月下载测试版抢先体验一番。由于公众和开发人员都使用该软件,所以苹果公司为两者推出了developer和public版即开发者测试版的公共测试版。iOS的developer版和public版有什么区别呢?从字面上的意思来说,developer版是开发者测试版,public版是公共测试版。developer版和public版面向的对象不同。developer版是苹果公司给开发者测试使用的,需要苹果开发者帐号才可以收到下载并升级,是

随着Web应用程序的普及,富文本编辑器成为Web开发中必不可少的一个工具。而在使用Go语言进行Web开发时,我们也需要选择一个适合的富文本编辑器控件来丰富我们的网站和应用程序。在本文中,我们将会探讨Go语言Web开发常见的富文本编辑器控件。FroalaEditorFroalaEditor是一款流行的富文本编辑器控件,被广泛应用于Web开发中。它具有现代化

When the HMD Skyline(available on Amazon for $499) was launched last month, it was released in two colors - Neon Pink and Twisted Black. They are now joined by a third color dubbed Blue Topaz. HMD Global has also announced an official case for the ph

switchcase判断变量,需要具体代码示例在编程中,我们经常需要根据不同的变量值来执行不同的操作。switchcase语句是一种方便的结构,可以根据变量的值来选择不同的代码块进行执行。下面是一个具体的代码示例,展示了如何使用switchcase语句判断变量的不同取值:#includeintmain(){

br是Adobe公司开发的一个组织工具程序,其全称是Adobe Bridge;br可以借助于编写ExtendScript脚本或使用内含的工作流程脚本示例将Adobe Creative Suite中各组件的繁重任务实现自动化。

这篇文章将为大家详细讲解有关PHP格式化一个GMT/UTC日期/时间,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。格式化PHP中的GMT/UTC日期/时间简介在php中,格式化GMT/UTC日期/时间对于正确显示和处理跨时区日期至关重要。本文将介绍如何使用PHP的DateTime类格式化GMT/UTC日期/时间,以及各种可用的格式化选项。DateTime类DateTime类表示一个日期和时间。它可以存储和操作GMT/UTC等时区中的日期/时间值。要创建新的Da

br在html中是一个换行标签,它用于在HTML文档中插入一个简单的换行符;在需要手动换行地方,加入“<br>”即可实现内容换行。“<br>”标签是一个空标签,意味着它没有结束标签。

panel控件的使用步骤是首先创建了一个Panel控件,并设置了其宽度、高度、背景颜色、边框颜色、边框宽度和内边距,创建了两个按钮,并将它们添加到Panel控件中,最后将Panel控件添加到窗体中。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver CS6
視覺化網頁開發工具

禪工作室 13.0.1
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Atom編輯器mac版下載
最受歡迎的的開源編輯器