请教怎么通过post方式通过HTTP向对方发送*xml文件

请问如何通过post方式通过HTTP向对方发送*xml文件

请问如何通过post方式通过HTTP向对方发送*xml文件

是不是和发送字符串的道理是一样的呢?一句一句的把*.xml文件的内容写成字符串,然后发送?

我请各位帮我写一小段代码,就行,这个我不太明白!

------解决方案--------------------
可以是xml字符串或者是XmlDom对象
------解决方案--------------------
<%@ Page Language= "C# " ValidateRequest= "false " %>
<%@ Import Namespace = "System.Net "%>
<%@ Import Namespace = "System.IO "%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<script runat= "server ">


protected void Button1_Click( object sender, EventArgs e )
{
Encoding encoding = Encoding.GetEncoding( "GB2312 ");
string strTitle = TextBox1.Text;
string postData = "xml= " + strTitle;
string strUrl = "http://localhost:3120/WebSite1/XmlReceive.aspx ";

byte[] data = encoding.GetBytes(postData);
// 准备请求...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
myRequest.Method = "POST ";
myRequest.ContentType = "application/x-www-form-urlencoded ";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// 发送数据
newStream.Write(data, 0, data.Length);
newStream.Close();
WebResponse response = myRequest.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.UTF8);
Response.Write( "返回结果: ");
Response.Write(sr.ReadToEnd());
resStream.Close();
sr.Close();

}
</script>

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server " Height= "246px " TextMode= "MultiLine " Width= "572px "> &lt;a&gt;a&lt;/a&gt; </asp:TextBox>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Button " /> </div>
</form>
</body>
</html>


XmlReceive.aspx
==================
<%@ Page Language= "C# " ValidateRequest= "false " %>
<script runat= "server ">

protected void Page_Load( object sender, EventArgs e )
{
if (Request.Form[ "xml "] == null)
{
Response.Write( "Error ");
}
else
{
Response.Write(Server.HtmlEncode(Request.Form[ "xml "].ToString()));
}
}
</script>


------解决方案--------------------
HttpWebRequest request = null;
CookieContainer cookie = null;
StreamReader reader = null;
try
{
cookie = new CookieContainer();

byte[] data = System.Text.Encoding.ASCII.GetBytes( "user=dier&pass=123456 " );
request = (HttpWebRequest)WebRequest.Create( "http://www.test.com/chklogin.asp " );
request.Method = "POST ";