xml post(C#)
xmlpost by HttpWebRequest:
protected string PostXmlToURL(string url,string data)
{
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url);
hwr.Method = "POST";
Stream stream = hwr.GetRequestStream();
StreamWriter sw = new StreamWriter(stream, System.Text.Encoding.UTF8);
sw.Write(data);
sw.Close();
stream = hwr.GetResponse().GetResponseStream();
StreamReader sr = new StreamReader(stream);
string result = sr.ReadToEnd();
sr.Close();
return result;
}
xmlpost by XMLHTTP:
发送请求.
StreamReader sr=new StreamReader(Server.MapPath(XMLPathFull));
MSXML2.XMLHTTPClass xmlHttp = new MSXML2.XMLHTTPClass();
xmlHttp.open("post",strURL,false,"","");
xmlHttp.setRequestHeader ("Content-type","text/xml;charset=UTF-8");
xmlHttp.send(sr.ReadToEnd());
//得到response
string backxmlstring=xmlHttp.responseText.ToString();
解读响应.
byte[] buf = Request.BinaryRead(Request.ContentLength);
string str = System.Text.Encoding.UTF8.GetString(buf);
xmlpost by js:
<script language="javascript" type="text/javascript">
function PostXml(url, data) {
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.Open("POST", url, false);
xmlhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.SetRequestHeader("Content-Length", d
相关文档:
一、本章主要介绍.NET XML序列化,构建XML序列化的框架类,主要放在你的框架项目里面,类名字命名为Serialiser,我的框架项目名称是MingXu.FrameWork,我将Serialiser放到它下面,MingXu.FrameWork类型为Class Library
二、序列化类用到了2个dll,分别为:
System.Xml.Serialization:X ......
文章来源:IT工程技术网 http://www.systhinker.com/html/43/n-11643.html
用的是一种很笨的方法,但可以帮助初学者了解访问XML节点的过程。
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
......
ID.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="ID.css"?>
<bookdetail>
<book class="A" id="B1">
<author>曹雪芹</author>
<title>红楼梦</title>
<price>60.00</price>
</book>
<book class="A ......