1.文件路径
右键xml文件,选择属性,Build Action 选择Content,此时xml文件就在项目根目录下,直接引用xml文件名即可。
2.遍历节点
private ReadXML() { XmlDocument doc = new XmlDocument(); string attribute1= string.Empty; string attribute2 = string.Empty; string sqlColumnName = string.Empty; doc.Load(fileName); var tables = doc.SelectNodes(@"/Node1/table"); foreach (XmlElement table in tables) { attribute1 = table.Attributes["attributeNameOrIndex"].Value;
attribute2 = table.Attributes["attributeNameOrIndex"].Value;
foreach (XmlElement field in table.SelectNodes("column[@scope='all' or @scope='oracle']"))
{
sqlColumnName = field.Attributes["name"].Value; //result.Add(field.FirstChild.Attributes["displayName"].Value, "");
//.........
); } } }