本文整理汇总了C#中System.Xml.Linq.XElement.XPathSelectElement方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.XPathSelectElement方法的具体用法?C# XElement.XPathSelectElement怎么用?C# XElement.XPathSelectElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.XPathSelectElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
// ARRANGE
var assemblyPath = typeof(TestManualElementsCommand).Assembly.Location;
var cmdletXmlHelpPath = Path.ChangeExtension(assemblyPath, ".dll-Help.xml");
if (File.Exists(cmdletXmlHelpPath))
{
File.Delete(cmdletXmlHelpPath);
}
// ACT
var options = new Options(false, assemblyPath);
var engine = new Engine();
engine.GenerateHelp(options);
// ASSERT
Assert.That(File.Exists(cmdletXmlHelpPath));
using (var stream = File.OpenRead(cmdletXmlHelpPath))
{
var document = XDocument.Load(stream);
rootElement = document.Root;
}
testManualElementsCommandElement = rootElement.XPathSelectElement("command:command[command:details/command:name/text() = 'Test-ManualElements']", resolver);
testMamlElementsCommandElement = rootElement.XPathSelectElement("command:command[command:details/command:name/text() = 'Test-MamlElements']", resolver);
testReferencesCommandElement = rootElement.XPathSelectElement("command:command[command:details/command:name/text() = 'Test-References']", resolver);
testInputTypesCommandElement = rootElement.XPathSelectElement("command:command[command:details/command:name/text() = 'Test-InputTypes']", resolver);
}
示例2: Parse
public static AssemblyDoc Parse(XElement doc)
{
return new AssemblyDoc
{
Name = doc.XPathSelectElement("assembly/name").Value,
Types = ParseMembers(doc.XPathSelectElement("members"))
};
}
示例3: FromXml
public static PersonalConfiguration FromXml(XElement root)
{
lock (m_syncRoot) {
string name = root.XPathSelectElement("./configuration/personalConfiguration/name").Value;
string address = root.XPathSelectElement("./configuration/personalConfiguration/address").Value;
return new PersonalConfiguration(name, address);
}
}
示例4: FromXml
public static DirectoriesConfiguration FromXml(XElement root)
{
lock (m_syncRoot) {
XElement xElement = null;
xElement = root.XPathSelectElement("./configuration/directoriesConfiguration/defaultTouchDirectory");
string defaultTouchDirectory = xElement.Value;
xElement = root.XPathSelectElement("./configuration/directoriesConfiguration/lastTouchDirectory");
string lastTouchDirectory = xElement.Value;
return new DirectoriesConfiguration(defaultTouchDirectory, lastTouchDirectory);
}
}
示例5: FromXml
public static ExceptionRecord FromXml(XElement exceptionData)
{
if (exceptionData == null)
return null;
return new ExceptionRecord {
Type = exceptionData.XPathSelectElement("type[1]").Value,
Message = exceptionData.XPathSelectElement("message[1]").Value,
Stacktrace = exceptionData.XPathSelectElement("stacktrace[1]").Value
.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(),
InnerEception = !string.IsNullOrEmpty(exceptionData.XPathSelectElement("innerexception[1]").Value)
? FromXml(exceptionData.XPathSelectElement("innerexception[1]").Elements().First())
: null
};
}
示例6: ParagraphIsStageDirection
public bool ParagraphIsStageDirection (XElement paragraph)
{
var next = paragraph.XPathSelectElement ("key[text()='speaker']").NextNode as XElement;
var body = next.Value;
return body == "STAGE DIRECTION";
}
示例7: FromXml
public static GeneralConfiguration FromXml(XElement root)
{
lock (m_syncRoot) {
XElement xElement = root.XPathSelectElement("./configuration/generalConfiguration/useRecursionByDefault");
bool useRecursionByDefault = Convert.ToBoolean(xElement.Attribute("useRecursionByDefault").Value);
return new GeneralConfiguration(useRecursionByDefault);
}
}
示例8: DoesElementExist
public static bool DoesElementExist(XElement xElement, string xPathStatement)
{
bool result = false;
if (xElement.XPathSelectElement(xPathStatement) != null)
{
result = true;
}
return result;
}
示例9: DoesElementHaveValue
public static bool DoesElementHaveValue(XElement xElement, string xPathStatement)
{
bool result = false;
if (string.IsNullOrEmpty(xElement.XPathSelectElement(xPathStatement).Value) == false)
{
result = true;
}
return result;
}
示例10: CardViewModel
public CardViewModel(XElement e)
{
Title = (string)e.XPathSelectElement("title");
IssueKey = (string)e.XPathSelectElement("key");
ProjectName = (string)e.XPathSelectElement("project");
Assignee = (string)e.XPathSelectElement("assignee");
Summary = (string)e.XPathSelectElement("summary");
OriginalEstimate = (string)e.XPathSelectElement("timeoriginalestimate");
Status = (string)e.XPathSelectElement("status");
ProjectKey = (string)e.XPathSelectElement("project").Attribute("key");
}
示例11: ParseErrorInfo
private ErrorInfo ParseErrorInfo(XElement errorInfoXmlElement)
{
XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
xmlNamespaceManager.AddNamespace("prefix", ns.NamespaceName);
errorInfoXmlElement = errorInfoXmlElement.Element(ns + "Output");
XElement messageElement = errorInfoXmlElement.XPathSelectElement("prefix:ErrorInfo/prefix:Message", xmlNamespaceManager);
string message = (messageElement != null) ? messageElement.Value : null;
XElement stackTraceElement = errorInfoXmlElement.XPathSelectElement("prefix:ErrorInfo/prefix:StackTrace", xmlNamespaceManager);
string stackTrace = (stackTraceElement != null) ? stackTraceElement.Value : null;
XElement stdOutElement = errorInfoXmlElement.XPathSelectElement("prefix:StdOut", xmlNamespaceManager);
string stdOut = (stdOutElement != null) ? stdOutElement.Value : null;
return new ErrorInfo(message, stackTrace, stdOut);
}
示例12: GetBooleanValue
public static bool GetBooleanValue(XElement xElement, string xPathStatement, bool defaultValue)
{
bool result = defaultValue;
if (DoesElementExist(xElement, xPathStatement) == true)
{
if (DoesElementHaveValue(xElement, xPathStatement) == true)
{
result = Convert.ToBoolean(xElement.XPathSelectElement(xPathStatement).Value);
}
}
return result;
}
示例13: GetIntValue
public static int GetIntValue(XElement xElement, string xPathStatement, int defaultValue)
{
int result = defaultValue;
if (DoesElementExist(xElement, xPathStatement) == true)
{
if (DoesElementHaveValue(xElement, xPathStatement) == true)
{
result = Convert.ToInt32(xElement.XPathSelectElement(xPathStatement).Value);
}
}
return result;
}
示例14: SetValue
public static void SetValue(XElement xElement, string xPathStatement, string elementValue)
{
if (DoesElementExist(xElement, xPathStatement) == false)
{
string[] slashSplit = xPathStatement.Split('/');
XElement parentElement = xElement.XPathSelectElement('/' + slashSplit[1]);
AddElement(parentElement, slashSplit[2]);
}
XElement element = xElement.XPathSelectElement(xPathStatement);
element.Value = elementValue;
}
示例15: GetStringValue
public static string GetStringValue(XElement xElement, string xPathStatement, string defaultValue)
{
string result = defaultValue;
if (DoesElementExist(xElement, xPathStatement) == true)
{
if (DoesElementHaveValue(xElement, xPathStatement) == true)
{
result = xElement.XPathSelectElement(xPathStatement).Value.ToString();
}
}
return result;
}