XML Oh, interesting, heard a joke, said an old man in Germany, is a deaf, in the toilet, suddenly Soviet warplanes air raids, although the house collapsed, but the whole family did not matter, the family to pull out the toilet wall, found the old man there, said: "I pull a flush toilet rope, the house fell."
hahaha, I also like this, just I one of this post, chinaasp is over, thought it was my thing, it is the Soviet plane to fry, hehe.
If you like to play with XML, then follow me, but before you do, please take a deep breath as I introduce you to a long code that reveals a Web Form control that Microsoft hides in the ASP.net architecture, that is, <asp:xml runat=server/> I only give code, do not give explanations, everyone to study after class.
In addition, because it is beta1, you cannot use <XSL:SORT> in the XSLT you use in this control, and, of course, you cannot use that order-by, because it supports the XSL space with "1999" instead of the original one.
In addition, the answer I get from Microsoft is in Beta2, it will support <xsl:sort>, and by then, my brother will all turn to xml+xsl, now for the source code confidentiality problem to get a very headache.
Take a look at the following example:
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;
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 ("\ r \ n");
}
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 + "<" + name + ">" + value);
Outputq.append ("\ r \ n");
}
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 < reader.) Depth; i++)
{
Outputxml.append (' t ');
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.