XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(file);
XmlNodeList name = xmlDoc.GetElementsByTagName("Name");
XmlNodeList description = xmlDoc.GetElementsByTagName("Description");
XmlNodeList synonymname = xmlDoc.GetElementsByTagName("Synonym_Name");
XmlNodeList typeflag = xmlDoc.GetElementsByTagName("Type_Flag");
XmlNodeList loopflag = xmlDoc.GetElementsByTagName("Loop_Flag");
XmlNodeList pacgroups = xmlDoc.GetElementsByTagName("Pac_Groups");
XmlNodeList grouid = xmlDoc.GetElementsByTagName("Grou_Id");
XmlNodeList funcid = xmlDoc.GetElementsByTagName("Func_Id");
答案 0 :(得分:0)
var nodeNames = new [] { "Name", "Description", "Synonym_Name" };
var nodeContents = nodeNames
.Select(xmlDoc.GetElementsByTagName)
.Select(_ => _.Cast<XmlNode>())
.SelectMany(_ => _)
.Select(node =>
{
var stringBuilder = new StringBuilder();
var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true };
using (var writer = XmlTextWriter.Create(stringBuilder, settings))
{
node.WriteTo(writer);
writer.Flush();
return stringBuilder.ToString();
}
});
var box = new System.Windows.Controls.TextBox();
box.Text = string.Concat(nodeContents);