I need to read an xml file that is encoded in ISO-8859-1.
I'm using:
Document document = reader.read(new File(sourceFile));
document.setXMLEncoding("ISO-8859-1");
I'm getting a "cannot find symbol"
error for setXMLEncoding
. This seems like it should be a simple thing, but I can't figure out what I'm doing wrong.
The
setXMLEncoding
is available sincedom4j
1.6. I guess you're using an older version.Anyway, as the javadoc says:
you should use that method if you're writing an xml. I guess you're reading an existing file, so if it's
ISO-8859-1
encoded and its prolog contains the same encoding declaration, you shouldn't have any problem,dom4j
should do everything for you.