@@ -11,6 +11,13 @@ class XmlElementReader(abc.ABC):
1111 Provides an interface for extracting element text, attributes and sub-elements.
1212 """
1313
14+ @property
15+ @abc .abstractmethod
16+ def tag (self ) -> str :
17+ """
18+ Xml element tag.
19+ """
20+
1421 @abc .abstractmethod
1522 def is_empty (self ) -> bool :
1623 """
@@ -45,6 +52,14 @@ def find_element(
4552 :return: xml element
4653 """
4754
55+ @abc .abstractmethod
56+ def get_text (self ) -> Optional [str ]:
57+ """
58+ Returns the element text.
59+
60+ :return: element text
61+ """
62+
4863 @abc .abstractmethod
4964 def pop_text (self ) -> Optional [str ]:
5065 """
@@ -63,6 +78,14 @@ def pop_attrib(self, name: str) -> Optional[str]:
6378 :return: element attribute
6479 """
6580
81+ @abc .abstractmethod
82+ def get_attributes (self ) -> Optional [Dict [str , str ]]:
83+ """
84+ Returns the element attributes.
85+
86+ :return: element attributes
87+ """
88+
6689 @abc .abstractmethod
6790 def pop_attributes (self ) -> Optional [Dict [str , str ]]:
6891 """
@@ -92,6 +115,14 @@ def find_sub_element(self, path: Sequence[str], search_mode: 'SearchMode') -> Op
92115 :return: found element or `None`
93116 """
94117
118+ @abc .abstractmethod
119+ def get_elements (self ) -> Optional [List ['XmlElement[Any]' ]]:
120+ """
121+ Returns the element sub-elements.
122+
123+ :return: sub-element
124+ """
125+
95126 @abc .abstractmethod
96127 def create_snapshot (self ) -> 'XmlElement[Any]' :
97128 """
@@ -306,6 +337,9 @@ def append_element(self, element: 'XmlElement[NativeElement]') -> None:
306337 def get_attrib (self , name : str ) -> Optional [str ]:
307338 return self ._state .attrib .get (name , None ) if self ._state .attrib else None
308339
340+ def get_text (self ) -> Optional [str ]:
341+ return self ._state .text
342+
309343 def pop_text (self ) -> Optional [str ]:
310344 result , self ._state .text = self ._state .text , None
311345
@@ -314,6 +348,9 @@ def pop_text(self) -> Optional[str]:
314348 def pop_attrib (self , name : str ) -> Optional [str ]:
315349 return self ._state .attrib .pop (name , None ) if self ._state .attrib else None
316350
351+ def get_attributes (self ) -> Optional [Dict [str , str ]]:
352+ return self ._state .attrib
353+
317354 def pop_attributes (self ) -> Optional [Dict [str , str ]]:
318355 result , self ._state .attrib = self ._state .attrib , None
319356
@@ -358,6 +395,9 @@ def find_element(
358395
359396 return searcher (self ._state , tag , look_behind , step_forward )
360397
398+ def get_elements (self ) -> Optional [List ['XmlElement[NativeElement]' ]]:
399+ return self ._state .elements [self ._state .next_element_idx :]
400+
361401
362402class SearchMode (str , Enum ):
363403 """
0 commit comments