我有一个字符串设置为Xml。这是一个数据集,我填充然后返回字符串getXml()。尽管xml循环并显示警报中的值
我想抓取子类别下的所有值,并显示每个子类别的警报显示。
我想是这样的,但迟迟不来右:
$.parseXML(xml).find('Table').each(function(index){
var SubCategorySystem = $(this).find('SubCategorySystem').text();
var SubCategory = $(this).find('SubCategory').text();
alert(SubCategory);
});
这是我的字符串的样子。
<NewDataSet>
<Table>
<SubCategorySystem>Building</SubCategorySystem>
<SubCategory>Building</SubCategory>
</Table>
<Table>
<SubCategorySystem>Electrical</SubCategorySystem>
<SubCategory>Electrical</SubCategory>
</Table>
<Table>
<SubCategorySystem>Engineering</SubCategorySystem>
<SubCategory>Engineering</SubCategory>
</Table>
<Table>
<SubCategorySystem>Inspection</SubCategorySystem>
<SubCategory>Inspection</SubCategory>
</Table>
<Table>
<SubCategorySystem>Landscaping</SubCategorySystem>
<SubCategory>Landscaping</SubCategory>
</Table>
<Table>
<SubCategorySystem>Mechanical</SubCategorySystem>
<SubCategory>Mechanical</SubCategory>
</Table>
<Table>
<SubCategorySystem>Painting</SubCategorySystem>
<SubCategory>Painting</SubCategory>
</Table>
<Table>
<SubCategorySystem>Plumbing</SubCategorySystem>
<SubCategory>Plumbing</SubCategory>
</Table>
<Table>
<SubCategorySystem>Safety & Security</SubCategorySystem>
<SubCategory>Safety & Security</SubCategory>
</Table>
</NewDataSet>"
什么也正是不工作这两个功能? – melancia