@@ -34,7 +34,7 @@ def find_element(
3434 search_mode : 'SearchMode' ,
3535 look_behind : bool = True ,
3636 step_forward : bool = True ,
37- ) -> Optional ['XmlElement[Any] ' ]:
37+ ) -> Optional ['XmlElementReader ' ]:
3838 """
3939 Searches for an element with the provided tag.
4040
@@ -73,7 +73,7 @@ def pop_attributes(self) -> Optional[Dict[str, str]]:
7373 """
7474
7575 @abc .abstractmethod
76- def pop_element (self , tag : str , search_mode : 'SearchMode' ) -> Optional ['XmlElement[Any] ' ]:
76+ def pop_element (self , tag : str , search_mode : 'SearchMode' ) -> Optional ['XmlElementReader ' ]:
7777 """
7878 Extracts a sub-element from the xml element matching `tag`.
7979
@@ -83,7 +83,7 @@ def pop_element(self, tag: str, search_mode: 'SearchMode') -> Optional['XmlEleme
8383 """
8484
8585 @abc .abstractmethod
86- def find_sub_element (self , path : Sequence [str ], search_mode : 'SearchMode' ) -> Optional ['XmlElement[Any] ' ]:
86+ def find_sub_element (self , path : Sequence [str ], search_mode : 'SearchMode' ) -> Optional ['XmlElementReader ' ]:
8787 """
8888 Searches for an element at the provided path. If the element is not found returns `None`.
8989
@@ -106,6 +106,14 @@ def apply_snapshot(self, snapshot: 'XmlElement[Any]') -> None:
106106 Applies a snapshot to the current element.
107107 """
108108
109+ @abc .abstractmethod
110+ def to_native (self ) -> Any :
111+ """
112+ Transforms current element to a native one.
113+
114+ :return: native element
115+ """
116+
109117
110118class XmlElementWriter (abc .ABC ):
111119 """
@@ -165,7 +173,7 @@ def make_element(self, tag: str, nsmap: Optional[NsMap]) -> 'XmlElement[Any]':
165173 """
166174
167175 @abc .abstractmethod
168- def find_element_or_create (self , tag : str , search_mode : 'SearchMode' , nsmap : Optional [NsMap ]) -> 'XmlElement[Any] ' :
176+ def find_element_or_create (self , tag : str , search_mode : 'SearchMode' , nsmap : Optional [NsMap ]) -> 'XmlElementWriter ' :
169177 """
170178 Searches for an element with the provided tag.
171179 If the element is found returns it otherwise creates a new one.
@@ -176,6 +184,16 @@ def find_element_or_create(self, tag: str, search_mode: 'SearchMode', nsmap: Opt
176184 :return: xml element
177185 """
178186
187+ @classmethod
188+ @abc .abstractmethod
189+ def from_native (cls , element : Any ) -> 'XmlElement[Any]' :
190+ """
191+ Creates a instance of `XmlElement` from native element.
192+
193+ :param element: native element
194+ :return: `XmlElement`
195+ """
196+
179197
180198NativeElement = TypeVar ('NativeElement' )
181199
0 commit comments