mirror of
https://github.com/berkeleydb/libdb.git
synced 2024-11-16 09:06:25 +00:00
48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
/*-
|
|
* See the file LICENSE for redistribution information.
|
|
*
|
|
* Copyright (c) 2009, 2012 Oracle and/or its affiliates. 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);
|
|
}
|
|
|
|
}
|
|
}
|