diff options
Diffstat (limited to 'OpenSim/Framework/Configuration/XML/XmlConfiguration.cs')
-rw-r--r-- | OpenSim/Framework/Configuration/XML/XmlConfiguration.cs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs index e56c657..5b66035 100644 --- a/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs +++ b/OpenSim/Framework/Configuration/XML/XmlConfiguration.cs | |||
@@ -47,10 +47,19 @@ namespace OpenSim.Framework.Configuration | |||
47 | fileName = file; | 47 | fileName = file; |
48 | } | 48 | } |
49 | 49 | ||
50 | private void LoadDataToClass() | ||
51 | { | ||
52 | rootNode = doc.FirstChild; | ||
53 | if (rootNode.Name != "Root") | ||
54 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
55 | |||
56 | configNode = rootNode.FirstChild; | ||
57 | if (configNode.Name != "Config") | ||
58 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
59 | } | ||
50 | public void LoadData() | 60 | public void LoadData() |
51 | { | 61 | { |
52 | doc = new XmlDocument(); | 62 | doc = new XmlDocument(); |
53 | |||
54 | if (File.Exists(fileName)) | 63 | if (File.Exists(fileName)) |
55 | { | 64 | { |
56 | XmlTextReader reader = new XmlTextReader(fileName); | 65 | XmlTextReader reader = new XmlTextReader(fileName); |
@@ -67,14 +76,7 @@ namespace OpenSim.Framework.Configuration | |||
67 | rootNode.AppendChild(configNode); | 76 | rootNode.AppendChild(configNode); |
68 | } | 77 | } |
69 | 78 | ||
70 | 79 | LoadDataToClass(); | |
71 | rootNode = doc.FirstChild; | ||
72 | if (rootNode.Name != "Root") | ||
73 | throw new Exception("Error: Invalid .xml File. Missing <Root>"); | ||
74 | |||
75 | configNode = rootNode.FirstChild; | ||
76 | if (configNode.Name != "Config") | ||
77 | throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); | ||
78 | 80 | ||
79 | if (createdFile) | 81 | if (createdFile) |
80 | { | 82 | { |
@@ -82,6 +84,13 @@ namespace OpenSim.Framework.Configuration | |||
82 | } | 84 | } |
83 | } | 85 | } |
84 | 86 | ||
87 | public void LoadDataFromString(string data) | ||
88 | { | ||
89 | doc = new XmlDocument(); | ||
90 | doc.LoadXml(data); | ||
91 | |||
92 | LoadDataToClass(); | ||
93 | } | ||
85 | public string GetAttribute(string attributeName) | 94 | public string GetAttribute(string attributeName) |
86 | { | 95 | { |
87 | string result = null; | 96 | string result = null; |