For the below xml ,I need to replace for to
In case if xmlstarlet (a command line toolkit to query/edit/check/transform XML documents) is accessible:
xmlstarlet ed -u "//studentAction/studentStatus[preceding-sibling::studentType[1][text() = 'Juniour'] \
and ancestor::student/studentName[text() = 'CLASSA']]" -v failed students.xml
The above will output the initial XML document with needed replacement
The command details:
ed -u - edit/update mode
//studentAction/studentStatus - xpath expression to select studentStatus element which has:
preceding-sibling::studentType[1][text() = 'Juniour'] - preceding sibling element studentType with value Juniourancestor::student/studentName[text() = 'CLASSA'] - nearest element studentName with value CLASSA