Question: I need some help with writing a python script with a cross file find and replace function dealing with XML documents. I have 4 documents

I need some help with writing a python script with a cross file find and replace function dealing with XML documents. I have 4 documents that the teacher has given me. How would I write a script prompting the user for the text to find and the text to replace it with and then act on all files in a Data directory at the same level as the script. You could create simple XML documents as an example or if need be I will attach them.

This is the set up I have:

from lxml import etree

xml1Doc = etree.parse('c:\Barkeep.xml') xml2Doc = etree.parse('c:\City_Guard.xml') xml3Doc = etree.parse('c:\Farmer.xml') xml4Doc = etree.parse('c:\Traveling_Salesmen.xml')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!