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>
Ïà¹ØÎĵµ£º
using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Text;
// ÏàÓ¦C#´úÂ룺
private string ConvertDataTableToXML(DataTable xmlDS)
{
MemoryStream stream = null;
XmlTextWriter writer = null;
try
{
stream = new MemoryStream();
writer = new XmlTextWriter(stream, E ......
Ó¦ÓÃJSP£¬XMLºÍCSS¼¼ÊõʵÏÖµ¯³öʽ²Ëµ¥µÄ¹¤³Ì¿ò¼Ü¡£
×ۺϲÉÓÃJSP£¬JavaBean£¬XML£¬XSL£¬CSS£¬JavaScript¶àÏî¼¼ÊõµÄÓŵ㡣
ÔÚJSPÖÐʹÓÃXMLÎĵµ£¬XML¶¨ÒåÊý¾Ý¸ñʽ£¬ÔÚJSPÖÐÖ±½ÓÉú³ÉXMLÎļþ£¬ËüÓëJavaBean½»»¥£¬JavaBean¸ºÔð¶ÁÈ¡´æ´¢²Ëµ¥ÏîµÄÎļþ¡£
XSLʵÏÖXMLµ½HTMLµÄת»¯£¬CSSÎļþ¸ºÔðÑùʽµ¥µÄ¶¨Ò壬¶øJavaS ......
½ñÌì¼ÌÐø½²XML£¬ÕùÈ¡ÔÚÏÂÎç5µãǰռÁìXML¸ßµØ¡£Ò»¹²Èý¸öÖ÷ÒªÄÚÈÝ£ºSAX½âÎö¼¼Êõ£¬DOM4JºÍSCHEMA¡£
Ê×ÏÈÊÇSAX½âÎö¼¼Êõ£ºSAX²ÉÓÃʼþ´¦ÀíµÄ·½Ê½½âÎöXMLÎļþ¡£ÀûÓà SAX ½âÎö XML Îĵµ£¬Éæ¼°Á½¸ö²¿·Ö£º½âÎöÆ÷ºÍʼþ´¦ÀíÆ÷¡£
½âÎöÆ÷¸ºÔð¶ÁÈ¡ XML Îĵµ£¬²¢Ïòʼþ´¦ÀíÆ÷·¢ËÍʼþ
ʼþ´¦ÀíÆ÷¸ºÔð¶Ôʼþ×ö³öÏàÓ¦£¬¶Ô´«µÝµÄ XML Êý¾Ý ......
×î³£¼ûµÄXMLÊý¾ÝÀàÐÍÓУºElement, Attribute£¬Comment, Text.
Element, Ö¸ÐÎÈç<Name>Tom<Name>µÄ½Úµã¡£Ëü¿ÉÒÔ°üÀ¨£ºElement, Text, Comment, ProcessingInstruction, CDATA, and EntityReference.
Attribute, Ö¸ÔÚ<Employee >Ö ......