spring读取XML属性
XML文本样式
<clinic>
<!-- 诊疗费价表 去掉挂号费-->
<clinicpricedict>
<clinictypelist clinictype = "急诊" price = "6.00"></clinictypelist>
<clinictypelist clinictype = "专家门诊" price = "9.00"></clinictypelist>
</clinicpricedict>
<!-- 其他特殊配置 -->
<others>
<other othertype = "age" othervalue = "60">60</other> <!-- 年龄减免划分条件,减免发法在服务中 -->
</others>
</clinic>
读取XML文件,iterator迭代器,查看迭代器是否有下级(iterator.hasNext),没有就自动迭代循环,有下一级就读取下一级,然后再循环判断,使用递归判断每个节点是否有需要的属性attribute,有则获取属性attributeValue,没有就继续迭代。
代码:
public class XmlAnalytic {