遍历xml转换成datatable,绑定数据源 ///
/// 读取Xml
///
/// XmlDocument
/// 读取路径
///
public bool XmlLoad(XmlDocument doc,string path)
{
try
{
doc.Load(path); return true;
}
catch (Exception e)
{
return false;
}
} ///
/// 保存Xml
///
/// XmlDocument
/// 保存路径
///
public bool XmlSave(XmlDocument doc, string path)
{
try
{
doc.Save(path);
return true;
}
catch (Exception e)
{
return false;
}
} ///
/// 遍历xml节点,转换为HashTable
///
/// XmlDocument
/// Xml文件路径
///
public Hashtable XmlToHashTable(XmlDocument doc,string path)
{
Hashtable hs = new Hashtable(); if (!XmlLoad(doc, path))
{ }
else
{
if (doc.ChildNodes[0].ChildNodes.Count > 0)
{
for (int i = 0; i < doc.ChildNodes[0].ChildNodes.Count; i++)
{
hs.Add(i, doc.ChildNodes[0].ChildNodes[i].ChildNodes[0].Value);
}
}
}
return hs;
}doc.ChildNodes[0].ChildNodes[i].ChildNodes[0].Value//注意weue,fjghr,fjgmb,这些不是