Thanks Steve, I can't remove the declaration at source as it is coming from a host of places. When using the E4X approach I ended up doing a string replace ie
Code: Select all
fileContent = fileContent.replace(/<\?xml.{2,}?>/g, '');
That said I had a ferret about and found
org.json eg
Code: Select all
var fileJSONstr = new org.json.XML.toJSONObject(fileContent);
It's happier with the declarations and then outputs the response direct as json.
Out of interest the work I'm on with is Domain-based Message Authentication, Reporting & Conformance (DMARC)
https://dmarc.org/
I don't need to understand the finer details as I'm reporting on the emails we get from the main email providers.