| 发表于:2007-03-27 16:42:045楼 得分:20 |
'注释: load saved values from xml. private sub loadvalues(filepath) dim xml_document as domdocument dim values_node as ixmldomnode '注释: load the document. set xml_document = new domdocument 'xml_document.load m_apppath & "values.xml " xml_document.load filepath '注释: if the file doesn注释:t exist, then '注释: xml_document.documentelement is nothing. if xml_document.documentelement is nothing then '注释: the file doesn注释:t exist. do nothing. exit sub end if '注释: find the values section. set values_node = xml_document.selectsinglenode( "police ") '注释: read the saved values. txtfirstname.text = getnodevalue(values_node, "groupid ", "??? ") txtlastname.text = getnodevalue(values_node, "sn ", "??? ") txtstreet.text = getnodevalue(values_node, "name ", "??? ") txtcity.text = getnodevalue(values_node, "reason ", "??? ") txtstate.text = getnodevalue(values_node, "comment ", "没有 ") 'txtzip.text = getnodevalue(values_node, "reason ", "??? ") end sub private sub populatetreecontrol( _ byval document as system.xml.xmlnode, _ byval nodes as _ system.windows.forms.treenodecollection) dim node as system.xml.xmlnode for each node in document.childnodes ' if the element has a value, display it; ' otherwise display the first attribute ' (if there is one) or the element name ' (if there isn 't) dim [text] as string if node.value <> nothing then [text] = node.value else if not node.attributes is nothing and node.attributes.count > 0 then [text] = node.attributes(0).value else [text] = node.name end if end if dim new_child as new treenode([text]) nodes.add(new_child) populatetreecontrol(node, new_child.nodes) next node end sub | | |
|