Skip to content

Instantly share code, notes, and snippets.

@arnaldoleandro
Created April 3, 2023 10:39
Show Gist options
  • Save arnaldoleandro/be5dd30b23e22416b22700dc76c838f7 to your computer and use it in GitHub Desktop.
Save arnaldoleandro/be5dd30b23e22416b22700dc76c838f7 to your computer and use it in GitHub Desktop.
stores xml's root tag
def get_root_tag(input_file):
with open(input_file, 'r', encoding='utf-8') as file:
file.readline()
second_line = file.readline().strip()
root_tag = second_line[1:].split(' ', 1)[0]
return root_tag[:-1] if root_tag.endswith('>') else root_tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment