Monday, February 25, 2019

How to parse xml using python

I have the below xml file :





cq:lastReplicated="{Date}2016-03-02T15:23:40.679-05:00"
cq:lastReplicatedBy="XXXXt"
cq:lastReplicationAction="Activate"
jcr:description="Procedure"
jcr:mixinTypes="[cq:ReplicationStatus]"
jcr:primaryType="cq:Tag"
jcr:title="Lung Volume Reduction Surgery"
sling:resourceType="cq/tagging/components/tag"/>



I am trying to parse the XML file using ElementTree but I am not able to extract "Lung Volume Reduction Surgery" which is under the tag jcr:title .



I have already tried with BeatifulSoup , Regex and ElementTree but unable to do it



Below is the code that I used for Element Tree :



import xml.etree.ElementTree as ET
xml="Actual xml document"
xml.find('./root').attrib['title']



I am a beginner in XML parsing .. and spent more than 3 hours now on this XML file but unable to parse the value of jcr:title Any help will be greatly appreciated

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...