//查找指定的元素元素
Element element = this.findCreate(name);
element.setAttribute(attr, value);
saveProperties();
}
public void deleteProperty(String name) throws IOException
{
if(propertyCache.containsKey(name))
propertyCache.remove(name);
Element element = this.findOnly(name);
if(element != null) element.detach();
saveProperties();
}
public void deleteProperty(String name, String attr) throws IOException
{
String nameAttr = name + ":" + attr;
if(propertyCache.containsKey(nameAttr))
propertyCache.remove(nameAttr);
Element element = this.findOnly(name);
if(element != null) element.removeAttribute(attr);
saveProperties();
}
public String[] getChildrenProperties(String parent)
{
//分解元素的名称
String[] propName = parsePropertyName(parent);
Element element = doc.getRootElement();
//遍历搜索匹配的元素
for (int i = 0; i < propName.length; i++)
{
element = element.getChild(propName[i]);
//没有匹配的元素,返回一个空的数组
if(element == null) return new String[]{};
}
//找到啦!
List children = element.getChildren();
String[] childrenName = new String[children.size()];
for (int i = 0; i < children.size(); i++)
{
childrenName[i] = ((Element)children.get(i)).getName();
}
return childrenName;
}