Initialize with path to XML file and parse with line number tracking. Args: xml_path: Path to XML file to edit (str or Path) Raises: ValueError: If the XML file does not exist
(self, xml_path)
| 53 | """ |
| 54 | |
| 55 | def __init__(self, xml_path): |
| 56 | """ |
| 57 | Initialize with path to XML file and parse with line number tracking. |
| 58 | |
| 59 | Args: |
| 60 | xml_path: Path to XML file to edit (str or Path) |
| 61 | |
| 62 | Raises: |
| 63 | ValueError: If the XML file does not exist |
| 64 | """ |
| 65 | self.xml_path = Path(xml_path) |
| 66 | if not self.xml_path.exists(): |
| 67 | raise ValueError(f"XML file not found: {xml_path}") |
| 68 | |
| 69 | with open(self.xml_path, "rb") as f: |
| 70 | header = f.read(200).decode("utf-8", errors="ignore") |
| 71 | self.encoding = "ascii" if 'encoding="ascii"' in header else "utf-8" |
| 72 | |
| 73 | parser = _create_line_tracking_parser() |
| 74 | self.dom = defusedxml.minidom.parse(str(self.xml_path), parser) |
| 75 | |
| 76 | def get_node( |
| 77 | self, |
nothing calls this directly
no test coverage detected