我的 html 代码是这样的
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","brands.xml",false);
xmlhttp.send();
theXmlDoc=xmlhttp.responseXML;
function fillForm(){
$(theXmlDoc).find('table[name=brands]').each(function(){
alert($(this));//doesn't fire when brands.xml contains more than one entry of <table name="brands"> else shows Object object
});
我的brands.xml是
<table name="brands">
<column name="BrandID">1</column>
<column name="BrandName">AX</column>
<column name="CompanyInfo">FDC</column>
<column name="Composition">Cap</column>
</table>
<table name="brands">
<column name="BrandID">2</column>
<column name="BrandName">UP</column>
<column name="CompanyInfo">Tor</column>
<column name="Composition">Asp</column>
</table>
当brands.xml
包含单个<table name="brands">
警报条目时显示对象对象,但是当我包含多个表名时,如上所示,每个表名都没有被执行。