Provides implementation for xml request. This class cannot be inherited.
public sealed class XmlRequest: Object, IDisposable
ObjectXmlRequest
// This sample shows how to implement the XmlRequest class.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Net;
using System.Xml;
public class MyForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
public MyForm()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1
= new System.Windows.Forms.Button();this.button1.Location = new System.Drawing.Point(10, 10);
this.button1.Text = "Download";
this.Size = new System.Drawing.Size(400,300);
this.button1.Click += new EventHandler(on_click);
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox1.Location = new System.Drawing.Point(10, 45);
this.textBox1.Multiline= true;
this.textBox1.WordWrap= false;
this.textBox1.ScrollBars= ScrollBars.Both;
this.textBox1.Size= new Size(380,245);
}
private void on_click( object sender, EventArgs e )
{
this.textBox1.Text = "downloading...\n";
XmlRequest req= new XmlRequest();
req.StateChanged += new EventHandler(on_state_changed);
bool ok= req.Start("http://www.markme.com/notifications/flash.xml");
if( !ok )
this.textBox1.Text = "*** Start failed!\n";
}
private void on_state_changed( object sender, EventArgs e )
{
string msg;
XmlRequest req= (XmlRequest) sender;
{
case XmlRequestState.Success: msg= "Success!\n"; break;
case XmlRequestState.Cancelled: msg= "Cancelled\n"; break;
case XmlRequestState.Error: msg= "Error\n"; break;
case XmlRequestState.Running: msg= "Running\n"; break;
case XmlRequestState.Timeout: msg= "Timeout\n"; break;
default: msg="<unknown>\n;"; break;
}
if( req.State == XmlRequestState.Success )
{
XmlDocument doc= req.Response;
XmlNode rdf= doc.FirstChild;
foreach( XmlNode node in rdf.ChildNodes )
{
{
foreach( XmlAttribute attr in node.Attributes )
this.textBox1.AppendText( "channel=" + attr.Name + " " + attr.Value + "\n" );
}
else if( node.Name == "item" )
{
foreach( XmlAttribute attr in node.Attributes )
this.textBox1.AppendText( "channel=" + attr.Name + " " + attr.Value + "\n" );
}
}
}
}
static void Main()
{
Application.Run( new MyForm() );
}
}
Namespace System.Net Flash Library System.XML.scl Flash Library Version 2.0.0.1690 Silverlight Library System.XML.dll
| © 2003-2007 NETiKA Technologies. All rights reserved. |