AJAXʹÓÃjson½âÎöÓëʹÓÃxml½âÎöµÄ±È½Ï
¹¤¾ß:myeclipse 6.5
jsonÖÐÎĹٷ½£ºhttp://www.json.org/json-zh.html
н¨ÏîÄ¿webs£¬ÔÚWebRootÏÂн¨Ä¿Â¼json
xmlµÄ½âÎö·½Ê½:
------------------------------------------------------------------
1.н¨NewFile.xml
<?xml version="1.0" encoding="UTF-8"?>
<userinfo>
<name>kava</name>
<city>wuhan</city>
<tel>88768675</tel>
</userinfo>
2.н¨xml_1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>xml</title>
<script type="text/javascript">
var xmlHttp;
function showDetails() {
xmlHttp = GetXmlHttpObject();
if (xmlHttp == null) {
return;
}
var url = "http://localhost:8080/webs/json/NewFile.xml
";
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function GetXmlHttpObject(){
var xmlHttp=null;
Ïà¹ØÎĵµ£º
¶Á£º
//´ò¿ªÄ³Îļþ(¼ÙÉèweb.configÔÚ¸ùĿ¼ÖÐ)
string filename=Server.MapPath("/") + @"WebApplication1\web.config";
XmlDocument xmldoc= new XmlDocument();
xmldoc.Load(filename);
//µÃµ½¶¥²ã½ÚµãÁбí
XmlNodeList topM=xmldoc.DocumentElement.ChildNodes;
foreach(XmlElement element in topM)
{
if(ele ......
×î½ü×öµÄÒ»¸öÏîÄ¿ÖÐÔËÓà xml Êý¾Ýµº¼¼Êõ£¬ËùÒÔ°ÑÊý¾Ýµº·½ÃæµÄ֪ʶ×ܽáһϡ£
XML Êý¾Ýµº £¨ data islands £©¾ÍÊDZ» html Ò³ÃæÒýÓûòÕß°üº¬µÄ xml Êý¾Ý£¬ÊÇ´Ó IE5 ¿ªÊ¼ÒýÈëµÄÒ»Ïî¼¼Êõ¡£¿ÉÒÔͨ¹ý xml ±êÇ©ºÜÇáËɽ«Êý¾Ýµº²åÈëµ½ html ÎĵµÖС£ÄÇôÔõô·ÃÎÊ xml Êý¾ÝµºµÄÊý¾ÝÄØ£¬ºÜ¼òµ¥£¬Í¨¹ý xml µÄ id ¡£ÔÚÒ³ ......
¡¡Ò»°ãÇé¿öÏ£¬Ê¹ÓÃAjaxÌá½»µÄ²ÎÊý¶àÊÇЩ¼òµ¥µÄ×Ö·û´®£¬¿ÉÒÔÖ±½ÓʹÓÃGET·½·¨½«ÒªÌá½»µÄ²ÎÊýдµ½open·½·¨µÄurl²ÎÊýÖУ¬´Ëʱsend·½·¨µÄ²ÎÊýΪnull¡£
ÀýÈç £º
¡¡¡¡ var url = "login.jsp?user=XXX&pwd=XXX";
¡¡¡¡xmlHttpRequest.open("GET",url,true);
¡¡¡¡xmlHttpRequset.send(null);
¡¡¡¡´ËÍ⣠......
public static IList<News> GetAllNews()
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load("Äã¶ÁÈ¡µÄµØÖ·£ºÀýÈç ......
ÔÚPerlÖнâÎöXMLµÄ·½·¨×î³£¼ûµÄ¾ÍÊÇʹÓà XML::DOM
ºÍ XML::SimpleÁË¡£
XML::DOM¹ýÓÚÅӴ󣬶øÇÒ½âÎö½á¹ûÊÇÒ»¸öDOMÊ÷£¬²Ù×÷Ò²²»·½±ã¡£
¶ÔÓÚСÐÍÇÒ²»¸´ÔÓµÄXMLÎļþ£¬XML::DOMÕæÊÇɱ¼¦ÓÃÅ£µ¶¡£
Õâʱ¾ÍÂÖµ½Çá±ãµÄXML::SimpleÉϳ¡ÁË¡£
XML::SimpleÈçÆäÃû£¬ÕæµÄºÜ¼òµ¥¡£¼ÙÉèXMLÄÚÈÝÈçÏ£º
<opt>
<user login= ......