summaryrefslogtreecommitdiff
path: root/db-4.8.30/test/scr037/XMLReader.cs
blob: 6bdaa3ec5f4f3acbc09f2f70e1859bdfa53b7f00 (plain)
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
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2009 Oracle.  All rights reserved.
 *
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.XPath;

namespace CsharpAPITest
{
	public class XMLReader
	{
		private static string path;

		public XMLReader(string XmlFileName)
		{
			path = XmlFileName;
		}

		public XmlElement GetXmlElement(string className, string testName)
		{
			XmlDocument doc = new XmlDocument();
			doc.Load(path);

			string xpath = string.Format("/Assembly/TestFixture[@name=\"{0}\"]/Test[@name=\"{1}\"]", className, testName);
			XmlElement testCase = doc.SelectSingleNode(xpath) as XmlElement;
			if (testCase == null)
				return null;
			else
				return testCase;
		}

		public static XmlNode GetNode(XmlElement xmlElement,
		    string nodeName)
		{
			XmlNodeList xmlNodeList = xmlElement.SelectNodes(nodeName);
			if (xmlNodeList.Count > 1)
				throw new Exception(nodeName + " Configuration Error");
			else
				return xmlNodeList.Item(0);
		}

	}
}