if (insertBefore || (insertImageBefore && !insertAfter)) {
// insert the tag before the imageXPath
list.add(parent.indexOf(node), mediaTag);
} else {
// insert the tag after the imageXPath
list.add(parent.indexOf(node) + 1, mediaTag);
}
// write it back to the file
OutputStream out = new BufferedOutputStream(new FileOutputStream(requestingDocumentPath));
OutputFormat outputFormat = new OutputFormat();