dim domxmldocument as system.xml .xmldocumentdim tmppath as string=apptempfi lepathdim xmlfi le as string=tmppath+" \testxml .xml"
'窗体加载事件private sub testxml_load(byval sender as system.object, byval e as system.eventargs)handlesmybase. load
'读xm l过程测试通过dim domxmldocument as system.xml .xmldocumentdim tmppath as string=apptempfi lepathdim xmlfi le as string=tmppath+" \testxml .xml"dim reader as system.xml .xmlreader=nothingt ryreader=new xml .xmltextreader(xmlfi le)
'reader.whi le reader.readme. lboxxml . items.add(reader.name+reader.value)end whi lecatch ex as exceptionmsgbox(ex.message)final lyif not (reader is nothing) thenreader.close()end ifend tryend sub
'载入xm l事件private sub btnxml load_cl ick(byval sender as system.object, byval e as system.eventargs)handles btnxml load.cl ick
'me. lboxxml . items.clear()
' '读xm l过程测试通过
'dim reader as system.xml .xmlreader=nothing
't ry
' reader=new xml .xmltextreader(xmlfi le)
'whi le reader.read
'me. lboxxml . items.add(reader.name+":"+reader.value)
'end whi le
'catch ex as exception
'msgbox(ex.message)
'final ly
' if not (reader is nothing) then
'reader.close()
'end ifend trydim ds as new dataset
t ry
'如果直接使用ds做datasource则不会展开datagrid用dv则能直接显示正确。ds.readxml(xmlfi le)dim tb as datatabledim dv as dataviewtb=ds.tables(0)dv=new dataview(tb)datagrid1 .datasource=dv
'datagrid1 .datamember="testxmlmember"
'datagrid1 .datamember="employeefname"
'dim dxd as new xmldatadocumentcatch ex as exceptionmsgbox(ex.message.tostring)end tryend sub
'保存新建xm l内容事件private sub btnsavenew_cl ick(byval sender as system.object, byval e as system.eventargs)handles btnsavenew.cl ickdim mytw as new xmltextwriter(tmppath+" \ testxmlwrite.xml", nothing)mytw.writestartdocument()mytw.formatting=formatting. i ndentedmytw.writestartelement("team")mytw.writestartelement("player")mytw.writeattributestring("name", "george zip")mytw.writeattributestring("position”, "qb")mytw.writeelementstring("nickname", "zippy")mytw.writeelementstring("jerseynumber",xmlconvert.tostring(7))mytw.writeendelement()mytw.writeendelement()mytw.writeenddocument()mytw.close()end sub
文件很大的情况下可以考虑手动实现数据更新适配器 比如手动实现一个 xml节点搜索/更新这样就不用重写整个 xml。
如果程序的i/o不是主要问题还是用实体类整个的写入更新吧毕竟数据的完整性是第一位的。
如是文章类的对该目录建一个 xml索引文件来存放文章的编号 url等用xml的attribute作为标记不同字段 内容页面可以用另外的 html或xml页面存放用l inq to xml操作数据效率不是很差个人观点。当搜索时候只要查询指定文件名 xml或文件类型就可以了。
更多信息请查看IT技术专栏
阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...
DMIT,最近动作频繁,前几天刚刚上架了日本lite版VPS,正在酝酿上线日本高级网络VPS,又差不多在同一时间推出了美国cn2 gia线路不限流量的美国云服务器,不过价格太过昂贵。丐版只有30M带宽,月付179.99 美元 !!目前美国云服务器已经有个4个套餐,分别是,Premium(cn2 gia线路)、Lite(普通直连)、Premium Secure(带高防的cn2 gia线路),Prem...
提速啦简单介绍下提速啦 是成立于2012年的IDC老兵 长期以来是很多入门级IDC用户的必选商家 便宜 稳定 廉价 是你创业分销的不二之选,目前市场上很多的商家都是从提速啦拿货然后去分销的。提速啦最新物理机活动 爆炸便宜的香港CN2物理服务器 和 日本CN2物理服务器香港CTG E5 2650 16G内存 20M CN2带宽 1T硬盘 150元/月日本CN2 E5 2650 16G内存 20M C...