pro open_spedas_template,filename=filename,template=template,statuscode=statuscode,statusmsg=statusmsg
catch,Error_status
if (Error_status NE 0) then begin
statusmsg = !ERROR_STATE.MSG
statuscode = -3
catch,/cancel
return
endif
file=filename
spd_ui_validate_file,file=file,statusmsg=statusmsg,statuscode=statuscode
if statuscode lt 0 then return
widget_control, /hourglass
xmldoc=obj_new('IDLffXMLDOMDocument')
xmldoc->Load,file=file
template=obj_new('spd_ui_template')
body=xmldoc->GetFirstChild()
if (body->GetNodeName() NE 'body') then begin
message,'Expected body node, got '+body->GetNodeName()
endif
sib=body->GetFirstChild()
while (sib->GetNodeName() EQ '#text') do begin
sib=sib->GetNextSibling()
endwhile
if (sib->GetNodeName() NE 'SPD_UI_TEMPLATE') then begin
message,'Expected SPD_UI_DOCUMENT node, got '+sib->GetNodeName()
endif
template->BuildFromDOMElement,sib
obj_destroy,xmldoc
statuscode=0
statusmsg=STRING(file,format='("SPEDAS template successfully read from ",A)')
return
end