XMLHttpRequest Òì²½´¦ÀíXMLµäÐÍÓ¦ÓÃ
ÉùÃ÷¶ÔÏóʵÀý
var xmlhttp = false;
//²úÉúÒ»¸öXMLHttpRequest¶ÔÏóʵÀý
getHTTPRequestObject();
function getHTTPRequestObject()
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
xmlhttp = false;
}
}
if(!xmlhttp && typeof XMLHttpRequest!= 'undefined')
{
xmlhttp = new XMLHttpRequest();
}
}
//»Øµ÷´¦Àí
function callback()
{
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
var xmlresponse = xmlhttp.responseXML.documentElement; //»ñÈ¡xml²Ù×÷¶ÔÏó
document.getElementById("divResponse").innerText = xmlhttp.responseText; //È«ÎÄÒýÓÃ
alert(xmlresponse.getElementsByTagName("message")[0].firstChild.data);//½ÚµãÊý¾ÝÒýÓÃ
}
}
}
//´¥·¢Ê¼þ
function btnClick()
{
xmlhttp.open("GET", "XMLFile.xml", true);
xmlhttp.onreadystatechange = callback;
xmlhttp.send(null);
}
XMLFile.xmlÎļþÄÚÈÝ£º
<?xml version="1.0" encoding="utf-8" ?>
<messages>
<message>
Hello!
</message>
</messages>
Ïà¹ØÎĵµ£º
Asp.Net XML²Ù×÷»ùÀà(ÐÞ¸Ä,ɾ³ý,ÐÂÔö,´´½¨)
2009-12-21 16:59
/**********************************************************************************
*
* ¹¦ÄÜ˵Ã÷:XML´¦Àí»ùÀà
* ×÷Õß: Áõ¹¦Ñ«;
* °æ±¾:V0.1(C#2.0);ʱ¼ä:2006-12-13
*
* ******************************************************************** ......
½ñÌì¼ÌÐø½²XML£¬ÕùÈ¡ÔÚÏÂÎç5µãÇ°Õ¼ÁìXML¸ßµØ¡£Ò»¹²Èý¸öÖ÷ÒªÄÚÈÝ£ºSAX½âÎö¼¼Êõ£¬DOM4JºÍSCHEMA¡£
Ê×ÏÈÊÇSAX½âÎö¼¼Êõ£ºSAX²ÉÓÃʼþ´¦ÀíµÄ·½Ê½½âÎöXMLÎļþ¡£ÀûÓà SAX ½âÎö XML Îĵµ£¬Éæ¼°Á½¸ö²¿·Ö£º½âÎöÆ÷ºÍʼþ´¦ÀíÆ÷¡£
½âÎöÆ÷¸ºÔð¶ÁÈ¡ XML Îĵµ£¬²¢Ïòʼþ´¦ÀíÆ÷·¢ËÍʼþ
ʼþ´¦ÀíÆ÷¸ºÔð¶Ôʼþ×ö³öÏàÓ¦£¬¶Ô´«µÝµÄ XML Êý¾Ý ......
·½·¨Ò»£º°´ÕÕXMLµÄ½á¹¹Ò»²½Ò»²½µÄ¹¹½¨XMLÎĵµ.
ͨ¹ý.Net FrameWork SDKÖеÄÃüÃû¿Õ¼ä"System.Xml"Öзâ×°µÄ¸÷ÖÖÀàÀ´ÊµÏÖµÄ
·½·¨¶þ£ºÖ±½Ó¶¨Ó°XMLÎĵµ£¬È»ºó±£´æµ½Îļþ¡£
ͨ¹ý"XmlDocument"ÀàÖеÄ"LoadXml"·½·¨
.aspxǰ̨´úÂë:
<%@ Page Language="C# ......
ҪʹÓÃdom4j¶ÁдXMLÎĵµ,ÐèÒªÏÈÏÂÔØdom4j°ü,dom4j¹Ù·½ÍøÕ¾ÔÚ http://www.dom4j.org/
Ä¿Ç°×îÐÂdom4j°üÏÂÔصØÖ·: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
½â¿ªºóÓÐÁ½¸ö°ü,½ö²Ù×÷XMLÎĵµµÄ»°°Ñdom4j-1.6.1.jar¼ÓÈ빤³Ì¾Í¿ÉÒÔÁË,Èç¹ûÐèҪʹÓÃXPathµÄ»°»¹ÐèÒª¼ÓÈë°üjaxen-1.1-beta-7.jar.
ÒÔÏÂ ......
WebService£¬¼òµ¥Ò»µã˵£¬¾ÍÊǸö¶ÔÍâµÄ½Ó¿Ú,ÀïÃæÓк¯Êý¿É¹©Íⲿ¿Í»§µ÷ÓÃ(×¢Òâ:ÀïÃæͬÑùÓпͻ§²»¿Éµ÷Óõĺ¯Êý).¼ÙÈôÎÒÃÇÊÇ·þÎñ¶Ë,ÎÒÃÇдºÃÁ˸öwebservice,È»ºó°ÑËü¸øÁË¿Í»§(ͬʱÎÒÃǸøÁËËûÃǵ÷ÓùæÔò),¿Í»§¾Í¿ÉÒÔÔÚ´Ó·þÎñ¶Ë»ñÈ¡ÐÅϢʱ´¦ÓÚÒ»¸öÏà¶Ô͸Ã÷µÄ״̬.¼´ÊÇ¿Í»§²»Á˽â(Ò²²»ÐèÒª)Æä¹ý³Ì,ËûÃÇÖ»»ñÈ¡Êý¾Ý. Webservice´«µ ......