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技术专栏
hostyun新上了香港cloudie机房的香港原生IP的VPS,写的是默认接入200Mbps带宽(共享),基于KVM虚拟,纯SSD RAID10,三网直连,混合超售的CN2网络,商家对VPS的I/O有大致100MB/S的限制。由于是原生香港IP,所以这个VPS还是有一定的看头的,这里给大家弄个测评,数据仅供参考!9折优惠码:hostyun,循环优惠内存CPUSSD流量带宽价格购买1G1核10G3...
licloud怎么样?licloud目前提供香港cmi服务器及香港CN2+BGP服务器/E3-1230v2/16GB内存/240GB SSD硬盘/不限流量/30Mbps带宽,$39.99/月。licloud 成立於2021年,是香港LiCloud Limited(CR No.3013909)旗下的品牌,主要提供香港kvm vps,分为精简网络和高级网络A、高级网络B,现在精简网络和高级网络A。现在...
Sharktech 鲨鱼机房商家我们是不是算比较熟悉的,因为有很多的服务商渠道的高防服务器都是拿他们家的机器然后部署高防VPS主机的,不过这几年Sharktech商家有自己直接销售云服务器产品,比如看到有新增公有云主机有促销活动,一般有人可能买回去自己搭建虚拟主机拆分销售的,有的也是自用的。有看到不少网友在分享到鲨鱼机房商家促销活动期间,有赠送开通公有云主机$50,可以购买最低配置的,$49/月的...