| 605 | return elems |
| 606 | |
| 607 | def _validate_names(self) -> None: |
| 608 | children: list[Any] |
| 609 | |
| 610 | if self.names: |
| 611 | if self.iterparse: |
| 612 | children = self.iterparse[next(iter(self.iterparse))] |
| 613 | else: |
| 614 | children = self.xml_doc.xpath( |
| 615 | self.xpath + "[1]/*", namespaces=self.namespaces |
| 616 | ) |
| 617 | |
| 618 | if is_list_like(self.names): |
| 619 | if len(self.names) < len(children): |
| 620 | raise ValueError( |
| 621 | "names does not match length of child elements in xpath." |
| 622 | ) |
| 623 | else: |
| 624 | raise TypeError( |
| 625 | f"{type(self.names).__name__} is not a valid type for names" |
| 626 | ) |
| 627 | |
| 628 | def _parse_doc( |
| 629 | self, raw_doc: FilePath | ReadBuffer[bytes] | ReadBuffer[str] |