xml parsing using minidom and python -
i have xml below.
<?xml version="1.0" encoding="utf-8"?> <samplexml>" <customproperty> <name>test1</name> <value>testvalue1</value> </customproperty> </samplexml>`
i trying values test1 , testvalue1. trying multiple ways not able values. how values not using "getelementsbytagname"name"/"value"" child nodes names keep on changing.
so assume not using name , value find text because changing. can use below should solve issue.also assume tag named same
import xml.etree.elementtree et tree = et.parse('sample.xml') child in tree.find('customproperty'): print(child.text)
for example code output below:
test1 testvalue1
your xml file seems have character @ ending, please change below.
<?xml version="1.0" encoding="utf-8"?> <samplexml> <customproperty> <name>test1</name> <value>testvalue1</value> </customproperty> </samplexml>
Comments
Post a Comment