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¡¢Êý¾ÝÀàÐÍÑéÖ¤ÎÊÌâ
Asp.NetËäÈ»ÓÐÑéÖ¤¿Ø¼þ£¬µ«ÊÇÓÐЩ¸´ÔÓµÄÑéÖ¤»¹Êǵô«µ½·þÎñÆ÷ÉϽøÐУ¬ÓÃjsËٶȺÍÐÔÄܶ¼±È½ÏºÃ
<script>
//¼ì²éÊÇ·ñΪÈÎÒâÊý£¨ÊµÊý£©
function isNumeric(strNumber) {
var newPar=/^(-|\+)?\d+(\.\d+)?$/
alert(newPar.test(strNumber)); }
//¼ ......
JavaScriptÊÇ»ùÓÚ¶ÔÏóµÄ£¬ÈκÎÔªËض¼¿ÉÒÔ¿´³É¶ÔÏó¡£È»¶ø£¬ÀàÐͺͶÔÏóÊDz»Í¬µÄ¡£±¾ÎÄÖУ¬ÎÒÃdzýÁËÌÖÂÛÀàÐͺͶÔÏóµÄһЩÌصãÖ®Í⣬¸üÖØÒªµÄÊÇÑо¿ÈçºÎд³öºÃµÄ²¢ÇÒÀûÓÚÖØÓõÄÀàÐÍ¡£±Ï¾¹£¬JavaScriptÕâÖÖÁ÷ÐеĽű¾ÓïÑÔÈç¹ûÄܹ»½øÐÐÁ¼ºÃµÄ·â×°£¬²¢ÐγÉÒ»¸öÅÓ´óµÄÀàÐͿ⣬¶ÔÓÚÖØÓÃÊǷdz£ÓÐÒâÒåµÄ¡£
ÍøÉ϶ÔÓÚprototypeµÄÎÄÕ弆 ......
ÔÚjavascriptÖеÄstring¶ÔÏóûÓÐtrim·½·¨£¬ËùÒÔtrim¹¦ÄÜÐèÒª×Ô¼ºÊµÏÖ£º
´úÂëÈçÏ£º
Java´úÂë
﹤scriptlanguage=”javascript”﹥
/**
*ɾ³ý×óÓÒÁ½¶ËµÄ¿Õ¸ñ
*/
String.prototype.trim=function(){
&nbs ......
ÔÎijö´¦: http://www.dnew.cn/post/196.htm
ÏÈ¿´ÏÂÏÂÃ漸ÖÖд·¨
1.function f(x){return x*x;};f(x);
2.(function(x){return x*x;})(x);
3.(function(x){return x*x;}(x));
µÚÒ»ÖÖÎÒÃÇÓ¦¸Ã¶¼ºÜÊìϤÁË£¬ÕâÊÇÎÒÃǾ³£Ê¹ÓõÄд·¨¡£µÚ¶þµÚÈýÖÖ¶¼ÊÇÄäÃûº¯ÊýµÄд·¨¡£
------------------------------------------------ ......