1
public void OpenXmlDoc(string xmlFile)
2
{
3
tvXml.Nodes.Clear();
4
5
//Initailize XML objects
6
XmlTextReader xmlR = new XmlTextReader(xmlFile);
7
XmlDocument xmlDoc = new XmlDocument();
8
xmlDoc.Load(xmlR);
9
xmlR.Close();
10
11
//navigate inside the XLM document & populate the tree
12
TreeNode tnXML = new TreeNode("GUI Test XML");
13
tvXml.Nodes.Add(tnXML);
14
15
XmlNode xnGuiNode = xmlDoc.DocumentElement;
16
XMLRecursion(xnGuiNode, tnXML);
17
18
tvXml.ExpandAll();
19
20
}
21
22
private void XMLRecursion(XmlNode xnGuiNode, TreeNode tnXML)
23
{
24
TreeNode tmpTN = new TreeNode(xnGuiNode.Name + " " + xnGuiNode.Value);
25
26
if (xnGuiNode.Value == "false")
27
{
28
tmpTN.ForeColor = System.Drawing.Color.Red;
29
}
30
31
tnXML.Nodes.Add(tmpTN);
32
33
//preparing recursive call
34
if (xnGuiNode.HasChildNodes)
35
{
36
XmlNode tmpXN = xnGuiNode.FirstChild;
37
while (tmpXN != null)
38
{
39
XMLRecursion(tmpXN, tmpTN);
40
tmpXN = tmpXN.NextSibling;
41
}
42
}
43
}
44

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
