objectProperty<T> function

T objectProperty<T>(
  1. XmlElement objElem,
  2. String property
)

Implementation

T objectProperty<T>(XmlElement objElem, String property) {
  var attr = objElem.getAttributeNode(property);

  if(attr!=null) {
    if(T == String) return attr.value as T;
    if(T == int) return int.parse(attr.value) as T;
    if(T == double) return double.parse(attr.value) as T;
  }else{
    try{
      var propelem = objElem.findElements(property).first;
      if(propelem!=null) {
        if(T == String) return propelem.text as T;
        if(T == int) return int.parse(propelem.text) as T;
        if(T == double) return double.parse(propelem.text) as T;
      }
    }catch(Exception){}
  }
  return null;
}