111,126
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("C:\\wireshark.XML");
foreach (XmlNode node in doc.GetElementsByTagName("packet"))
GetNodes(node);
}
static void GetNodes(XmlNode node)
{
if (node.Attributes["showname"] != null && node.Attributes["show"] != null)
Console.WriteLine("{0},{1}", node.Attributes["showname"].Value, node.Attributes["show"].Value);
foreach (XmlNode xn in node.ChildNodes)
GetNodes(xn);
}
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"C:\\wireshark.XML");
XmlNode root = xmlDoc.DocumentElement;
for (int i = 0; i < root.SelectNodes("packet").Count; i++)
{
int ch=root.SelectNodes("packet")[i].ChildNodes.Count;
for (int j = 0; i < ch; j++)
{
XmlNode field = root.SelectNodes("packet")[i].ChildNodes[j];
string showname = field.Attributes["showname"].Value;
string show = field.Attributes["show"].Value;
Console.WriteLine(showname);
Console.WriteLine(show);
int ch1 = field.ChildNodes.Count;
for (int k = 0; k < ch1; k++)
{
XmlNode fields = field.ChildNodes[k];
string showname1 = fields.Attributes["showname"].Value;
Console.WriteLine(showname1);
}
}
}
XmlDocument doc = new XmlDocument();
doc.Load("C:\\wireshark.XML");
foreach (XmlNode node in doc.GetElementsByTagName("proto"))
{
foreach (XmlNode xn in node.ChildNodes)
{
Console.WriteLine(xn.Attributes["showname"].Value + "," + xn.Attributes["show"].Value);
}
}