Hi Monks, I need to replace a tag in an XML file that resembles the following:
<students> <student> <name>John</name> <id>001</id> <gpa>A</gpa> </student> <student> <name>John</name> <id>002</id> <gpa>C</gpa> </student> </students>
How would I go about finding the second instance of John (whose id is '002') and replace his GPA of 'C' with a 'B'? Keep in mind that searching for a 'C' within the entire file and replacing it with the 'B' might not be optimal because many students might have a GPA of 'C'. Since the id tag is unique for each student, is there a way to search for that unique tag, then replace the following line (in this case it would be the gpa tag) with a new line containing the 'B' GPA? Any thoughts on this would be greatly appreciated. Thanks in advance!
In reply to How can I replace a line (tag) in an XML file? by perlPractioner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |