@@ -26,7 +26,8 @@ public static class XmlExtensions
26
26
/// </summary>
27
27
/// <param name="parent">The element to search</param>
28
28
/// <param name="name">The child element name to search for</param>
29
- /// <returns>An enumeration of child elements with the given name, or null if none are found.</returns>
29
+ /// <returns>An enumeration of child elements with the given name, or null if none
30
+ /// are found.</returns>
30
31
public static IEnumerable < XElement > GetChildElements ( this XElement parent , string name )
31
32
{
32
33
return parent . Descendants ( ) . Where ( e => String . Equals ( e . Name . LocalName , name ) ) ;
@@ -37,12 +38,14 @@ public static IEnumerable<XElement> GetChildElements(this XElement parent, strin
37
38
/// </summary>
38
39
/// <param name="parent">The element to search</param>
39
40
/// <param name="name">The child element name to search for</param>
40
- /// <param name="predicate">The additioinal condition to staify </param>
41
+ /// <param name="predicate">The additional condition to satisfy </param>
41
42
/// <returns>An enumeration of child elements with the given name that satisfy the predicate,
42
43
/// or null if none are found.</returns>
43
- public static IEnumerable < XElement > GetChildElements ( this XElement parent , string name , Func < XElement , bool > predicate )
44
+ public static IEnumerable < XElement > GetChildElements ( this XElement parent , string name ,
45
+ Func < XElement , bool > predicate )
44
46
{
45
- return parent . Descendants ( ) . Where ( e => String . Equals ( e . Name . LocalName , name ) && predicate ( e ) ) ;
47
+ return parent . Descendants ( ) . Where ( e => String . Equals ( e . Name . LocalName , name )
48
+ && predicate ( e ) ) ;
46
49
}
47
50
48
51
/// <summary>
@@ -63,13 +66,15 @@ public static XElement GetChildElement(this XElement parent, string name)
63
66
/// <param name="name">The child element name to search for</param>
64
67
/// <param name="predicate">Additional conditions over the desired child element</param>
65
68
/// <returns></returns>
66
- public static XElement GetChildElement ( this XElement parent , string name , Func < XElement , bool > predicate )
69
+ public static XElement GetChildElement ( this XElement parent , string name ,
70
+ Func < XElement , bool > predicate )
67
71
{
68
- return parent . Descendants ( ) . FirstOrDefault ( e => String . Equals ( e . Name . LocalName , name ) && predicate ( e ) ) ;
72
+ return parent . Descendants ( ) . FirstOrDefault ( e => String . Equals ( e . Name . LocalName , name )
73
+ && predicate ( e ) ) ;
69
74
}
70
75
71
76
/// <summary>
72
- /// Determines if the given element conatins a child element of the given name
77
+ /// Determines if the given element contains a child element of the given name
73
78
/// </summary>
74
79
/// <param name="element">The element to search</param>
75
80
/// <param name="name">The child element name to search for</param>
@@ -80,19 +85,22 @@ public static bool ContainsChildElement(this XElement element, string name)
80
85
}
81
86
82
87
/// <summary>
83
- /// Determines if the given element conatins a child element of the given name that staifies the specified predicate
88
+ /// Determines if the given element contains a child element of the given name that satisfies
89
+ /// the specified predicate
84
90
/// </summary>
85
91
/// <param name="element">The element to search</param>
86
92
/// <param name="name">The child element name to search for</param>
87
93
/// <param name="predicate">An additional condition on descendant elements</param>
88
94
/// <returns>true if the given child element exists, otherwise false</returns>
89
- public static bool ContainsChildElement ( this XElement element , string name , Func < XElement , bool > predicate )
95
+ public static bool ContainsChildElement ( this XElement element , string name ,
96
+ Func < XElement , bool > predicate )
90
97
{
91
- return element . Descendants ( ) . Any ( e => string . Equals ( e . Name . LocalName , name ) && predicate ( e ) ) ;
98
+ return element . Descendants ( ) . Any ( e => string . Equals ( e . Name . LocalName , name )
99
+ && predicate ( e ) ) ;
92
100
}
93
101
94
102
/// <summary>
95
- /// Determines if the given element conatins a child element with any of the provided names
103
+ /// Determines if the given element contains a child element with any of the provided names
96
104
/// </summary>
97
105
/// <param name="element">The element to search</param>
98
106
/// <param name="names">The child element names to search for</param>
@@ -103,13 +111,16 @@ public static bool ContainsChildElement(this XElement element, IEnumerable<strin
103
111
}
104
112
105
113
/// <summary>
106
- /// Determines if the given element conatins a child element with any of the provided names that satifies the given predicate
114
+ /// Determines if the given element contains a child element with any of the provided names that
115
+ /// satisfies the given predicate
107
116
/// </summary>
108
117
/// <param name="element">The element to search</param>
109
118
/// <param name="names">The child element names to search for</param>
110
- /// <param name="predicate">An additional condition to check on descendat elements</param>
111
- /// <returns>True if any child element has the specified name and satisfies the specified predicate.</returns>
112
- public static bool ContainsChildElement ( this XElement element , IEnumerable < string > names , Func < XElement , bool > predicate )
119
+ /// <param name="predicate">An additional condition to check on descendant elements</param>
120
+ /// <returns>True if any child element has the specified name and satisfies the specified
121
+ /// predicate.</returns>
122
+ public static bool ContainsChildElement ( this XElement element , IEnumerable < string > names ,
123
+ Func < XElement , bool > predicate )
113
124
{
114
125
return names . Any ( n => element . ContainsChildElement ( n , predicate ) ) ;
115
126
}
0 commit comments