Accessing non tree structured xml data in python -


i have several xml files want parse in python. aware of elementtree package in python, xml files aren't stored in tree structure. below example

<tag1 attribute1="at1" attribute2="at2">my files text annotated tool  create these xml files.</tag1> parts of text enclosed in xml tag, whereas others not.  <tag1 attribute1="at1" attribute2="at2"><tag2 attribute3="at3" attribute4="at4">some enclosed in multiple tags.</tag1></tag2> , have overlapping tags: <tag1 attribute1="at1" attribute2="at2">this example sentence <tag3 attribute5="at5">containing nested example sentence</tag3></tag1> 

whenever use elementtree function parse file, can access first tag. looking way parse tags , don't want tree structure. appreciated.

if have 1 xml fragment per line, parse each line individually.

for line in some_file:     # parse using et , getroot. 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -