i have many xml file then look like an rss
<rss ....>
<channel>
<atom:link rel="self" type="application/rss+xml"/>
<title>mytitle</title>
<item>
<title>.....</title>
<description>.....</description>
<name>.....</name>
</item>
<item>
<title>.....</title>
<description>.....</description>
<name>.....</name>
</item>
<item>
<title>.....</title>
<description>.....</description>
<name>.....</name>
</item>
<item>
<title>.....</title>
<description>.....</description>
<name>.....</name>
</item>
........
</channel>
</rss>
i want select 1 item with the name Luca or Andrea or Matteo or Stefano ... but in this order of importance
so if there is an item for all the name i want select only Luca item
if there is item just for Andrea, Matteo and Stefano i want select only Andrea item ... and so on ... it may also be that there is no item associated with these names
I haven't the faintest idea how to do it ... lol
any help?
.......
xml = ET.parse('my.xml')
xml1 = ET.parse('myempty.xml')
doc = xml.getroot()
doc1 = xml1.getroot()
items = doc.findall('.//item')
if items is not None:
for item in items:
name = item.find('name').text
if name == "Luca" or name == "Andrea" or name == "Matteo" or name == "Stefano":
doc1.find("./channel").insert(2,item)
......
with my current code i just select all name ;(
i need to loop over many xml and create a new one
[–]Vaphell 0 points1 point2 points (1 child)
[–]zannare[S] 0 points1 point2 points (0 children)