I am trying to parse a xml using stax but the error I get is:
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[414,47]
Message: The reference to entity "R" must end with the ';' delimiter.
Which get stuck on the line 414 which has P&Rinside the xml file. The code I have to parse it is:
public List<Vild> getVildData(File file){
    XMLInputFactory factory = XMLInputFactory.newFactory();
    try {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(Files.readAllBytes(file.toPath()));
        XMLStreamReader reader = factory.createXMLStreamReader(byteArrayInputStream, "iso8859-1");
        List<Vild> vild = saveVild(reader);
        reader.close();
        return vild;
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return Collections.emptyList();
}
private List<Vild> saveVild(XMLStreamReader streamReader) {
    List<Vild> vildList = new ArrayList<>();
    try{
        Vild vild = new Vild();
        while (streamReader.hasNext()) {
            streamReader.next();
            //Creating list with data
        }
    }catch(XMLStreamException | IllegalStateException ex) {
        ex.printStackTrace();
    }
    return Collections.emptyList();
}
I read online that the & is invalid xml code but I don't know how to change it before it throws this error inside the saveVild method. Does someone know how to do this efficiently?
 
     
    