js ½âÎö xml ÖеÄʱ¼ä - Web ¿ª·¢ / JavaScript
Çë½Ì¸÷λ£¡ÐèÇóÊÇÕâÑùµÄ£¬»ñÈ¡xmlÖеÄʱ¼ä¶Î¡£
ÀýÈ磺ÎÒÏë»ñÈ¡2010-1-1 µ½ 2010-2-2Ö®¼äµÄÊý¾Ý¡£
xmlÎļþ¸ñʽ
<voice id="000001" begintime="2010-1-1 1:1:1" endtime="2010-1-1 2:3:5" filename="E:/voices/v000001.wav"/>
ÎÒµÄJSÓ¦¸ÃÔõôȥ»ñÈ¡¡£
ÒòΪֻÄÜÓÃHTMLÎļþ¶ÁÈ¡xmlÎļþ£¬Ã»ÓÐJDK»òÈÝÆ÷µÄ»·¾³¡£
var xmlDoc;
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load("ChinaArea.xml");
var voices = xmlDoc.DocumentElement.getElementsByTagName("voice");
for(var i=0;i<voices.length;i++){
alert(voices[i].getAttribute("begintime")+" "+voices[i].getAttribute("endtime"));
}
voices[i].getAttribute("begintime")+" "+voices[i].getAttribute("endtime");
Ö÷ÒªÊÇÕâ¸ö£¬ÆäÓàµÄÍøÉÏÓкܶàÀý×Ó
ʱ¼ä½ô£¡ÎÒÖ»ÄܲÉÓöÁ³öÊý¾ÝÈ»ºó½øÐÐʱ¼äµÄ±È¶Ô¡£°¥£¡Ã»°ì·¨¡£ÉÏÍòÌõµÄÊý¾Ý²éʱ¼äÏ൱µÄÂý
Ïà¹ØÎÊ´ð£º
ÄÚÈÝÈçÌâ¡£¡£ÔÚC#Àï¸ÄÈçºÎÐ´ÄØ£¿
±¾À´Ë¼Â·ÊÇÏȱȶԽڵãÃû³Æ£¬ÈçÊǵϰ¾Í±£´æÒªÉ¾³ý½ÚµãµÄϱê·ÅÔÚÊý×éÀȻºóÑ»·É¾³ý£¬µ«·¢ÏÖ¡£¡£µ±ÎÒɾ³ýµÚÒ»¸öºó£¬ËùÓнڵãϱêÊýÁ¿¶¼·¢Éú¸Ä±ä¡£¡£
¾Í²»ÄÜÔÙ°´ÕÕ֮ǰ¼Í¼µÄ½Úµã ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ÎÒÓÃXmlDocumentÉú³ÉXML
XmlElement remarkNode = node.OwnerDocument.CreateElement("remark");
remark1Node.InnerXml = "";
Èç¹ûInnerXml¸³Öµ²»Îª¿Õ£¬ÔòÉú³ÉµÄ±ê¼ÇÊÇûÎÊÌâµÄ£¬±ÈÈ磺<r ......
<UserModel xmlns="http://tempuri.org/">
<Name>Liu</Name>
<Age>23</Age>
</UserModel>
ÔõôÓÃlinq to xml ²éѯ°ÑÉÏÃæµÄÒ»¸ö×Ö·û´® ͶӰ³ÉÒ»¸ ......
xmlÎļþ¸ñʽÈçÏÂ
XML code:
<?xml version="1.0" encoding="GB2312" ?>
<allproducts version="1.0">
<products>
<product name="prodId&quo ......