@@ -83,28 +83,29 @@ public static TType GetValue<TType>(this XElement element, IFormatProvider forma
8383 return ret ;
8484 }
8585
86- public static void RemoveEmptyNs ( this XElement doc )
86+ public static void RemoveEmptyNs ( this XContainer doc )
8787 {
8888 foreach ( var node in doc . Descendants ( ) )
8989 {
90- if ( node . Name . NamespaceName != "" )
91- continue ;
90+ if ( ! node . Name . NamespaceName . IsEmpty ( ) ) continue ;
9291
9392 node . Attributes ( "xmlns" ) . Remove ( ) ;
9493 if ( node . Parent != null )
94+ {
9595 node . Name = node . Parent . Name . Namespace + node . Name . LocalName ;
96+ }
9697 }
9798 }
9899
99- public static void AddChild ( this XElement parent , params XElement [ ] childrens )
100+ public static void AddChild ( this XContainer parent , params XElement [ ] childrens )
100101 {
101102 if ( childrens == null || parent == null ) return ;
102103 if ( childrens . Length < 1 ) return ;
103104
104105 parent . Add ( childrens ) ;
105106 }
106107
107- public static void AddAttribute ( this XElement parent , params XAttribute [ ] attributes )
108+ public static void AddAttribute ( this XContainer parent , params XAttribute [ ] attributes )
108109 {
109110 if ( attributes == null || parent == null ) return ;
110111 if ( attributes . Length < 1 ) return ;
@@ -122,7 +123,7 @@ public static XElement ElementAnyNs(this XContainer source, string name)
122123 return source . Elements ( ) . SingleOrDefault ( e => e . Name . LocalName == name ) ;
123124 }
124125
125- public static XmlDocument ToXmlDocument ( this XDocument document , LoadOptions options )
126+ public static XmlDocument ToXmlDocument ( this XDocument document )
126127 {
127128 using ( var reader = document . CreateReader ( ) )
128129 {
0 commit comments