while ( reader.read ( ) ) { //判斷當前讀取得節點類型 switch ( reader.nodetype ) { case xmlnodetype.element : s = reader.name ; break ; case xmlnodetype.text : if ( s.equals ( "name" ) ) myitem = listview1.items.add ( reader.value ) ; else myitem.subitems.add ( reader.value ) ; break ; } }
四.c#讀取xml的文件的源程序代碼(read.cs):
在了解了上面的內容以后,可以得到用c#讀取指定xml文件的完整代碼,具體如下:
using system ; using system.drawing ; using system.collections ; using system.componentmodel ; using system.windows.forms ; using system.data ; using system.xml ; public class form1 : form { private button button1 ; private listview listview1 ; private system.componentmodel.container components = null ;