@@ -6,6 +6,13 @@ namespace MessageParser.NET.Tools
66{
77 public class XmlParser
88 {
9+ /// <summary>
10+ /// Get Specified Attribute Value
11+ /// </summary>
12+ /// <param name="xmlString">Xml Text</param>
13+ /// <param name="element">Element Name</param>
14+ /// <param name="attribute">Attribute Name</param>
15+ /// <returns></returns>
916 public string GetAttributeValue ( string xmlString , string element , string attribute )
1017 {
1118 using ( XmlReader reader = XmlReader . Create ( new System . IO . StringReader ( xmlString ) ) )
@@ -16,6 +23,12 @@ public string GetAttributeValue(string xmlString, string element, string attribu
1623 }
1724 }
1825
26+ /// <summary>
27+ /// Get Specified Element Content
28+ /// </summary>
29+ /// <param name="xmlString">Xml Text</param>
30+ /// <param name="element">Element Name</param>
31+ /// <returns></returns>
1932 public string GetElementContent ( string xmlString , string element )
2033 {
2134 using ( XmlReader reader = XmlReader . Create ( new System . IO . StringReader ( xmlString ) ) )
@@ -25,6 +38,11 @@ public string GetElementContent(string xmlString, string element)
2538 }
2639 }
2740
41+ /// <summary>
42+ /// Get All Elements In Xml Text
43+ /// </summary>
44+ /// <param name="xmlString">Xml Text</param>
45+ /// <returns></returns>
2846 public string [ ] GetAllElements ( string xmlString )
2947 {
3048 using ( XmlReader reader = XmlReader . Create ( new System . IO . StringReader ( xmlString ) ) )
@@ -40,6 +58,12 @@ public string[] GetAllElements(string xmlString)
4058 return output . ToArray ( ) ;
4159 }
4260 }
61+
62+ /// <summary>
63+ /// Get All Text In Xml Text
64+ /// </summary>
65+ /// <param name="xmlString">Xml Text</param>
66+ /// <returns></returns>
4367 public string [ ] GetAllText ( string xmlString )
4468 {
4569 using ( XmlReader reader = XmlReader . Create ( new System . IO . StringReader ( xmlString ) ) )
@@ -67,6 +91,15 @@ public string[] GetAllText(string xmlString)
6791 // }
6892 //}
6993
94+ /// <summary>
95+ /// Set Attribute Value In A Node With The Specified Parent
96+ /// </summary>
97+ /// <param name="xmlString">Xml Text</param>
98+ /// <param name="parent">Parent Name</param>
99+ /// <param name="element">Element Name</param>
100+ /// <param name="attributeName">Attribute Name</param>
101+ /// <param name="value">Attribute Value</param>
102+ /// <returns></returns>
70103 public string SetAttribute ( string xmlString , string parent , string element , string attributeName , string value )
71104 {
72105 using ( XmlReader reader = XmlReader . Create ( new System . IO . StringReader ( xmlString ) ) )
@@ -97,6 +130,16 @@ public string SetAttribute(string xmlString, string parent, string element, stri
97130 }
98131 }
99132
133+ /// <summary>
134+ /// Set Attribute Value In A Node
135+ /// </summary>
136+ /// <param name="xmlString">Xml Text</param>
137+ /// <param name="element">Element Name</param>
138+ /// <param name="attributeName">Attribute Name</param>
139+ /// <param name="value">Attribute Value</param>
140+ /// <param name="allElements">Wethere Set ALL Attribute Value With Specified Name Or Only First Attribute
141+ /// :True Set All Attribute Value With Specified Name In Xml Text. :False Set Only First Attribute With Specified Name In Xml Text</param>
142+ /// <returns></returns>
100143 public string SetAttribute ( string xmlString , string element , string attributeName , string value , bool allElements )
101144 {
102145 StringBuilder output = new StringBuilder ( ) ;
@@ -154,6 +197,17 @@ public string SetAttribute(string xmlString, string element, string attributeNam
154197 return output . ToString ( ) ;
155198 }
156199
200+ /// <summary>
201+ /// Set Attribute Value In A Node
202+ /// </summary>
203+ /// <param name="xmlString">Xml Text</param>
204+ /// <param name="element">Element Name</param>
205+ /// <param name="attributeName">Attribute Name</param>
206+ /// <param name="value">Attribute Value</param>
207+ /// <param name="allElements">Wethere Set ALL Attribute Value With Specified Name Or Only First Attribute
208+ /// True Set All Attribute Value With Specified Name In Xml Text.
209+ /// False Set Only First Attribute With Specified Name In Xml Text</param>
210+ /// <returns></returns>
157211 public string SetAttribute ( XmlReader reader , string element , string attributeName , string value , bool allElements )
158212 {
159213 StringBuilder output = new StringBuilder ( ) ;
@@ -210,6 +264,12 @@ public string SetAttribute(XmlReader reader, string element, string attributeNam
210264 return output . ToString ( ) ;
211265 }
212266
267+ /// <summary>
268+ /// Check Wethere Exsist This Attribute Name In Xml Text.
269+ /// </summary>
270+ /// <param name="reader"></param>
271+ /// <param name="attributeName"></param>
272+ /// <returns></returns>
213273 public bool ISExsistAttribute ( XmlReader reader , string attributeName )
214274 {
215275 if ( reader . HasAttributes )
@@ -224,7 +284,13 @@ public bool ISExsistAttribute(XmlReader reader, string attributeName)
224284 return false ;
225285 }
226286
227-
287+ /// <summary>
288+ /// Update Specified Attribute Value
289+ /// </summary>
290+ /// <param name="reader"></param>
291+ /// <param name="writer"></param>
292+ /// <param name="attributeName"></param>
293+ /// <param name="value"></param>
228294 public void UpdateAttribute ( XmlReader reader , XmlWriter writer , string attributeName , string value )
229295 {
230296 bool flag = false ;
@@ -247,6 +313,11 @@ public void UpdateAttribute(XmlReader reader, XmlWriter writer, string attribute
247313 writer . WriteAttributeString ( null , attributeName , null , value ) ;
248314 }
249315
316+ /// <summary>
317+ /// Get SubTree
318+ /// </summary>
319+ /// <param name="xmlString"></param>
320+ /// <returns></returns>
250321 public string xmlSubTree ( string xmlString )
251322 {
252323 StringBuilder output = new StringBuilder ( ) ;
0 commit comments