日期:2014-05-19  浏览次数:21199 次

如何读取如下xml文件内容
下面的xml是用delphi导出来的数据,用c#如何读取文件内容并用datagridview显示出来?最好有读取的代码!
<xml   xmlns:s= 'uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882 '
xmlns:dt= 'uuid:C2F41010-65B3-11d1-A29F-00AA00C14882 '
xmlns:rs= 'urn:schemas-microsoft-com:rowset '
xmlns:z= '#RowsetSchema '>
<s:Schema   id= 'RowsetSchema '>
<s:ElementType   name= 'row '   content= 'eltOnly '   rs:updatable= 'true '>
<s:AttributeType   name= 'tname '   rs:number= '1 '   rs:nullable= 'true '   rs:writeunknown= 'true '   rs:basecatalog= 'p9_z4 '
  rs:basetable= 't_rbshlib '   rs:basecolumn= 'tname '>
<s:datatype   dt:type= 'string '   rs:dbtype= 'str '   dt:maxLength= '50 '/>
</s:AttributeType>
<s:AttributeType   name= 'sex '   rs:number= '2 '   rs:nullable= 'true '   rs:writeunknown= 'true '   rs:basecatalog= 'p9_z4 '
  rs:basetable= 't_rbshlib '   rs:basecolumn= 'sex '>
<s:datatype   dt:type= 'ui1 '   dt:maxLength= '1 '   rs:precision= '3 '   rs:fixedlength= 'true '/>
</s:AttributeType>
<s:AttributeType   name= 'tcode '   rs:number= '3 '   rs:nullable= 'true '   rs:writeunknown= 'true '   rs:basecatalog= 'p9_z4 '
  rs:basetable= 't_rbshlib '   rs:basecolumn= 'tcode '>
<s:datatype   dt:type= 'string '   rs:dbtype= 'str '   dt:maxLength= '50 '/>
</s:AttributeType>
<s:AttributeType   name= 'TID '   rs:number= '4 '   rs:writeunknown= 'true '   rs:basecatalog= 'p9_z4 '   rs:basetable= 't_rbshlib '
  rs:basecolumn= 'TID '   rs:keycolumn= 'true '   rs:hidden= 'true '>
<s:datatype   dt:type= 'i8 '   dt:maxLength= '8 '   rs:precision= '19 '   rs:fixedlength= 'true '   rs:maybenull= 'false '/>
</s:AttributeType>
<s:extends   type= 'rs:rowbase '/>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row   tname= '冯兴照 '   sex= '1 '   tcode= '055 '   TID= '4864 '/>
<z:row   tname= '张毓祥 '   sex= '1 '   tcode= '056 '   TID= '4865 '/>
<z:row   tname= '李建辉 '   sex= '1 '   tcode= '057 '   TID= '4866 '/>
<z:row   tname= '张福金 '   sex= '1 '   tcode= '058 '   TID= '4867 '/>
<z:row   tname= '张福金 '   sex= '1 '   tcode= '058 '   TID= '4868 '/>
<z:row   tname= '李志明 '   sex= '1 '   tcode= '059 '   TID= '4869 '/>
<z:row   tname= '何文和 '   sex= '1 '   tcode= '060 '   TID= '4870 '/>
</rs:data>
</xml>

------解决方案--------------------

今天刚做过, 参考一下:
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
Na