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
相关文档:
用的是一种很笨的方法,但可以帮助初学者了解访问XML节点的过程。
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
&n ......
Product.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="product.css" ?>
<productata>
<product prodid="p001" category="toy">
<productname>Mini Bus</productname>
<description>This is a toy for childern aged 4 and above&l ......
这是一篇讲解如何使用XML实现Flash与通信的入门级实例教程。通过本例的学习,我们将了解使用XML开发Flash RIAs的基本流程。
从Flash Player 5开始,就可以使用XML对象来实现Flash与后台通信。Flash浏览器与XML数据之间的直接进行数据交换,并且同LoadVars函数一样,都是以字符串形式传递的。后台语言作为XML数据和数据库 ......