JavaScript²Ù×÷XMLÎĵµ
×î½üÔÚѧXML£¬¿´ÊéµÄ¹ý³ÌÖÐ˳±ã×öµã±Ê¼Ç£¬¹©ÒÔºó²Î¿¼
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<mce:script language=javascript><!--
var oNodeMap,str,oList,item;
//´´½¨DOMDocument¶ÔÏó
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//²»ÔÊÐíÒì²½¼ÓÔØ£¬½Å±¾»áµÈ´ýÎĵµÈ«²¿±»ÏÂÔغó²ÅÖ´ÐдúÂë
xmlDoc.async = false;
//°ÑXMLÎĵµÔØÈëDOMDocument¶ÔÏó
xmlDoc.load("MyXml1.xml");
if(xmlDoc.parseError!= 0)//ÅжÏ×°Èë¹ý³ÌÖÐÊÇ·ñ²úÉú´íÎó
{
document.writeln(xmlDoc.parseError.reason+"<br>");
}
else
{
//»ñµÃ¸ùÔªËؽڵãµÄÊôÐÔ£¬²¢½«ÊôÐԵĸöÊýÊä³ö
oNodeMap = xmlDoc.documentElement.attributes;
document.writeln("¸ùÔªËؽڵãµÄÊôÐÔ¸öÊýΪ£º"+oNodeMap.length+"<br>");
//»ñµÃ¸ùÔªËؽڵãµÄÃû×Ö£¬²¢Êä³öµ½Ò³ÃæÉÏ
str = xmlDoc.documentElement.nodeName;
document.writeln("¸ùÔªËؽڵãµÄÃû×Ö£º"+str+"<br>");
//»ñµÃ¸ùÔªËؽڵãµÄ×ӽڵ㼯ºÏ
oList = xmlDoc.documentElement.childNodes;
//Êä³ö¸ö×Ó½ÚµãµÄÄÚÈÝ
document.writeln("¸÷×Ó½ÚµãµÄ¸öÊýΪ£º"+oList.length+"<br/>");
document.writeln("¸÷×Ó½ÚµãµÄÄÚÈÝΪ£º<br/>");
for(var i=0;i<oList.length;++i)
{
document.writeln(oList[i].xml+"<br/>");
}
}
var node = xmlDoc.documentElement.childNodes[0];
document.writeln("½ÚµãÀàÐÍ£º"+node.nodeType+"<br>");
document.writeln("¸ùÔªËؽڵãÃû³Æ£º"+node.ownerDocument.documentElement.tagName+"<br>");
document.writeln("µ±Ç°½ÚµãµÄÊôÐÔ"+node.attributes[0].value+"<br>");
document.writeln("µ±Ç°½Úµã¼°Æä×Ó½ÚµãËù°üº¬µÄÎı¾£º" +node.text+"<br>");
// --></mce:script>
</HEAD>
<BODY>
</BODY>
</HTML>
MyXml1.xmlµÄ´úÂëÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<person id="1" idd="2">
<person pid="E01">
<name>ÕÅÈý</name>
<address>½ËÕÊ¡ÐìÖÝÊÐ</address>
<tel>1456321</tel>
<email>zhangsan@16
Ïà¹ØÎĵµ£º
1. Javascript Debug Toolkit½éÉÜ
JSDT(Javascript Debug Toolkit)ÊÇÒ»¸öÓÃÓÚjavascriptµ÷ÊÔµÄeclipse
²å¼þ£¬ÓÃÓÚµ÷ÊÔjavascript¡£JSDT¿ÉÒÔ¿çä¯ÀÀÆ÷µ÷ÊÔ£¬Ö§³ÖÔÚIE,Firefox,Safari,ChromeµÈÖ÷Á÷ä¯ÀÀÆ÷Öе÷ÊÔ
javascript¡£JSDTÖ§³ÖÉèÖöϵ㣬µ¥²½µ÷ÊԵȵ÷ÊÔ¹¤¾ßµÄ»ù±¾ÌØÐÔ¡£
2. ÈçºÎ°²×°
JSDTÊÇ»ùÓÚeclipse3.2+,jdk1.5+ ......
³ýÁËÓÃgetElementByTagName µÄÁíÒ»ÖÖ»ñÈ¡¶ÔÏ󼯺ϵķ½·¨
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" conte ......
JavaScriptµÄä¯ÀÀÆ÷¶ÔÏóÏê½â
Ò»¡¢ä¯ÀÀÆ÷¶ÔÏó²ã´Î¼°ÆäÖ÷Òª×÷ÓÃ
¶þ¡¢Îĵµ¶ÔÏó¹¦Äܼ°Æä×÷ÓÃ
Èý¡¢·¶Àý
ʹÓÃä¯ÀÀÆ÷µÄÄÚ²¿¶ÔÏóϵͳ, ¿ÉʵÏÖÓëHTMLÎĵµ½øÐн»»¥¡£ËüµÄ×÷ÓÃÊǽ«Ïà¹ØÔªËØ×éÖ¯°ü×°ÆðÀ´£¬Ìṩ¸ø³ÌÐòÉè¼ÆÈËԱʹÓ㬴Ӷø¼õÇá±à³ÌÈ˵ÄÀͶ¯£¬Ìá¸ßÉè¼ÆWebÒ³ÃæµÄÄÜÁ¦¡£
Ò»¡¢ä¯ÀÀÆ÷¶ÔÏó²ã´Î¼°ÆäÖ ......