Espero que alguien vea el error :/
Código HTML:
import org.w3c.dom.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import java.io.*; public class Ex5 { public static void main(String[] args) throws IOException { File fichero = new File("Empleat.dat"); RandomAccessFile file = new RandomAccessFile(fichero, "r"); int pos=0, id, dep; Double salario; char apellido[] = new char[10], aux; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { DocumentBuilder bui = factory.newDocumentBuilder(); DOMImplementation imp = bui.getDOMImplementation(); Document doc = imp.createDocument(null, "persona", null); //Indiquem la versio del nostre xml doc.setXmlVersion("1.0"); for(;;) { //ens posicionem file.seek(pos); id=file.readInt(); for(int i=0; i<apellido.length; i++) { aux= file.readChar(); apellido[i]=aux; } String apellidoS = new String(apellido); dep=file.readInt(); salario=file.readDouble(); if(id<0) { Element raiz = doc.createElement("empleado"); doc.getDocumentElement().appendChild(raiz); CrearElemento("ID: ", Integer.toString(id), raiz, doc); CrearElemento("Apellido: ", apellidoS.trim(), raiz, doc); CrearElemento("salario: ",Double.toString(salario),raiz, doc); } pos = pos + 36; if(file.getFilePointer() == file.length()) break; } Source source = new DOMSource(doc); Result result = new StreamResult (new java.io.File("Empleados.xml")); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, result); } catch (Exception e) { System.out.print("Error: "+e); } file.close(); } static void CrearElemento (String datoEmple, String valor, Element raiz, Document document) { Element elem = document.createElement(datoEmple); Text text = document.createTextNode(valor); raiz.appendChild(elem); elem.appendChild(text); } }