如何遍历xml
xml文件如下,不知怎么遍历出所有值,求教
<?xml version="1.0" encoding="gb2312"?>
<userinfo>
<clas uid="1" uno="101" uname="a" utype="1">
<guid gname="wx" gtype="3" />
<home addr="" mobil="" mail=""/>
<friendm>
<friendm fnum="" fname="" />
</friendm>
<friendwm fnum="" fname=""/>
</clas>
<clas uid="2" uno="102" uname="b" utype="1">
<guid gname="we" gtype="3" />
<home addr="" mobil="" mail=""/>
<friendm>
<friendm fnum="" fname="" />
</friendm>
<friendwm fnum="" fname=""/>
</clas>
<clas uid="3" uno="1011" uname="c" utype="1">
<guid gname="zf" gtype="3" />
<home addr="" mobil="" mail=""/>
<friendm>
<friendm fnum="" fname="" />
</friendm>
<friendwm fnum="" fname=""/>
</clas>
</userinfo>
------解决方案--------------------把你问题的标题输入google都有答案。如果你明知这一点,那么你无非就是想找个苦力而已了。
------解决方案--------------------using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace ProjectTool
{
/// <summary>
/// xml文件操作类
/// </summary>
class XmlHelper
{
XmlDocument xmlDoc = new XmlDocument();
#region 获取指定目录下所有子节点的值
/// <summary>
/// 获取指定目录下所有子节点的值
/// </summary>
/// <param name="strFilePath">文件路径</param>
/// <param name="nodeDir">节点目录</param>
/// <returns></returns>
public Hashtable GetNodeList(string strFilePath, string nodeDir)
&n