GOA - System.Net.XmlRequest

XmlRequest Class


Provides implementation for xml request. This class cannot be inherited.

Definition

public sealed class XmlRequest: Object, IDisposable

Members Table

MethodDescription
AbortCancels a request to a xml file.
AddHeaderAdds an header to the request.
Dispose
EqualsOverloaded. Compares two objects to determine if they are equal. (Inherited from Object)
GetHashCodeServes as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object)
GetTypeGets the Type of the current instance. (Inherited from Object)
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
StartOverloaded. Starts the request.
ToStringReturns a String that represents the current Object. (Inherited from Object)
XmlRequestInitializes a new instance of XmlRequest.
PropertyDescription
ContentLengthGets the total size of the file to load.
LoadedPercentageGets the loaded percentage of the xml file.
LoadedSizeGets the size of the requested content already loaded.
ResponseGets the response of the request.
SpeedGets the speed of file loading.
StateGets the state of the request.
TimeoutGets or sets the timeout for the response.
XmlErrorGets an integer number which represents an Xml error.
EventDescription
StateChangedHandles the changes of the state of the request.

Inheritance Hierarchy

Object
XmlRequest

Examples

// 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.SuspendLayout();

          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.Text = "MyForm";

          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);

          this.textBox1.Text = "";

          this.Controls.Add(button1);

          this.Controls.Add(textBox1);

          this.ResumeLayout(false);

     }

 

     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;

          switch( req.State )

          {

               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;

          }

          this.textBox1.Text = msg;

          if( req.State == XmlRequestState.Success )

          {

               XmlDocument doc= req.Response;

               XmlNode rdf= doc.FirstChild;

               foreach( XmlNode node in rdf.ChildNodes )

               {

                    if( node.Name == "channel" )

                    {

                         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() );

     }

}

 

Class Information

NamespaceSystem.Net
Flash LibrarySystem.XML.scl
Flash Library Version2.0.0.1690
Silverlight LibrarySystem.XML.dll



© 2003-2007 NETiKA Technologies. All rights reserved.