-
Notifications
You must be signed in to change notification settings - Fork 3
/
XmlAnalyzer.cs
49 lines (42 loc) · 1.4 KB
/
XmlAnalyzer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace DesktopApp
{
//XmlAnalyzer class
internal static class XmlAnalyzer
{
//Analyzes the XML file and returns a list of name tags in the file.
public static List<string> Analyzer(string path)
{
var names = new List<string>();
var lines = File.ReadLines(path);
var lineIndex = 0;
IEnumerable<string> enumerable = lines.ToList();
var line = enumerable.ElementAt(lineIndex);
while (!line.Contains("</output>"))
{
var currentName = "";
if (line.Contains("<name>"))
{
var index = 0;
while (line[index++] != '>')
{
}
while (line[index] != '<')
{
currentName += line[index++];
}
if (names.Contains(currentName))
{
names[names.IndexOf(currentName)] = currentName + "1";
currentName += "2";
}
names.Add(currentName);
}
line = enumerable.ElementAt(++lineIndex);
}
return names;
}
}
}