Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
so what do I need to do if I want to search for 999 and print the whole "blub:Log"

I would find 999 by using
findLogIter = tree.find("999"), but how do I tell him to print the whole thing?

What I have tried:

The initial function:

Python
from xml.etree import ElementTree
tree = ElementTree.parse('sample.xml')
root = tree.getroot()

for item in root:
    print ','.join([sub_item.text for sub_item in item])

Data

HTML
<blub:LogEvents>
 <blub:Log>
  <blub:LogTime>09/03/2017 01:02:16.3216</blub:LogTime>
  <blub:LogIter>999</blub:LogIter>
  <blub:PlugInName>blub:System</blub:PlugInName>
  <blub:EventNumber>100</blub:EventNumber>
  <blub:EventName>I processed something/blub:EventName>
  <blub:EventClass>Process</blub:EventClass>
  <blub:LogMessage><![test message]]></blub:LogMessage>
 </blub:Log>
</blub:LogEvents>
Posted
Updated 10-Mar-17 4:35am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900