forked from domaindrivendev/Swashbuckle.AspNetCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXPathNavigatorExtensions.cs
More file actions
33 lines (27 loc) · 1.13 KB
/
XPathNavigatorExtensions.cs
File metadata and controls
33 lines (27 loc) · 1.13 KB
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
using System.Linq;
using System.Xml.XPath;
namespace Swashbuckle.AspNetCore.SwaggerGen;
internal static class XPathNavigatorExtensions
{
private const string EmptyNamespace = "";
internal static XPathNodeIterator SelectChildren(this XPathNavigator navigator, string name)
{
return navigator.SelectChildren(name, EmptyNamespace);
}
internal static string GetAttribute(this XPathNavigator navigator, string name)
{
return navigator.GetAttribute(name, EmptyNamespace);
}
internal static XPathNavigator SelectFirstChild(this XPathNavigator navigator, string name)
{
return navigator.SelectChildren(name, EmptyNamespace)
?.OfType<XPathNavigator>()
.FirstOrDefault();
}
internal static XPathNavigator SelectFirstChildWithAttribute(this XPathNavigator navigator, string childName, string attributeName, string attributeValue)
{
return navigator.SelectChildren(childName, EmptyNamespace)
?.OfType<XPathNavigator>()
.FirstOrDefault(n => n.GetAttribute(attributeName, EmptyNamespace) == attributeValue);
}
}