}
if(name.equals("/"+parent.getName())) {
return null;
}
TreeEntity entity = parent.addChild(name);
//Add Attributes
tag = tag.trim();
if(tag.length()>0) {
tag = tag.replace(" =", "=").replace("= ", "=");
String[] attributes = StringHelper.split(tag, " ", "\"", "\"");
for(String attribute: attributes) {
if(attribute.indexOf("=")==-1) {
continue;
}
String key = attribute.substring(0,attribute.indexOf("="));
attribute = attribute.substring(attribute.indexOf("=")+1);
String value = attribute.substring(attribute.indexOf("\"")+1,attribute.lastIndexOf("\""));
entity.setAttribute(key, value);
}
}
if(tag.length()!=0 && (tag.lastIndexOf('/')==tag.length()-1||tag.lastIndexOf('?')==tag.length()-1)) {
return entity;
}
TreeEntity child = parseEntity(entity,in);
while(child!=null) {
child = parseEntity(entity,in);
}
//String closeTag = parseTo(in,'>');