I need to retain the child nodes by deleting its parent node..
is it possible?
Example:
<?xml version="1.0" encoding="UTF-8"?>
<School>
<SSLC>
<name></name>
<rollno></rollno>
</SSLC>
<PUC>
<first_pu>
<name></name>
<rollno></rollno>
</first_pu>
<second_pu>
<name></name>
<rollno></rollno>
</second_pu>
</PUC>
</School>
I need to delete <PUC>
node. I have tried the following code:
String lineToRemove = "<PUC>";
String currentLine;
while ((currentLine = reader.readLine()) != null)
{
String trimmedLine = currentLine.trim();
if (trimmedLine.equals(lineToRemove)) continue;
writer.write(currentLine + System.getProperty("line.separator"));
}
But it's not working.