示例#1
0
 public void setAttribute(String name, String value) {
   StringTokenizer parser = new StringTokenizer(name, ".");
   MiniElement element = rootElement;
   String token = name;
   while (parser.countTokens() > 1) {
     token = parser.nextToken();
     MiniElement child = element.getElement(token);
     if (child == null) {
       child = new MiniElement(token);
       element.addElement(child);
     }
     element = child;
   }
   token = parser.nextToken();
   MiniAttribute attribute = element.getAttribute(token);
   if (attribute == null) {
     attribute = new MiniAttribute(token, value);
     element.addAttribute(attribute);
   } else {
     attribute.setValue(value);
   }
 }