PY
py
1
2
3
4
5
6
7
8
9
10
11
12
#need to extract 'eng' word from below xml file using minidom
from xml.dom.minidom import parse
import xml.dom.minidom
string = """<languageCommunication><languageCode code="eng" /><preferenceInd value="true" /></languageCommunication>"""
with open("Output.xml", "w") as xml_file:
xml_file.write(string)
DOMTree = xml.dom.minidom.parse(r"Output.xml")
language=DOMTree.getElementsByTagName("languageCommunication")[0]
print(language.firstChild.getAttribute("code"))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run