The processing instruction target matching "[xX][mM][lL]" is not allowed.

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

The processing instruction target matching "[xX][mM][lL]" is not allowed.

#1

Postby Steve James » Mon Oct 23, 2017 12:35 pm

Hi, I'm looping through an email inbox and extracting dozens of zip/gz file attachments. The content of hte attachment is an xml file.

They come from multiple sources and always contain version and may contain encoding.
When I try to read the content as an XML document I get the above error.
eg

Code: Select all

var fileXML = new XML(fileContent);
In the past I've just removed the top line via a string replace but how else could I do this. I can look for a regex if necessary but ......

Thanks
Steve
ps nice shiny new forum.
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

Re: The processing instruction target matching "[xX][mM][lL]" is not allowed.

#2

Postby Steve » Tue Oct 24, 2017 7:21 am

Hi Steve,

You usually see this message because there is a rogue character at the start of the XML declaration. Sometimes these characters are quite hard to find and you need to use something like notepad++ to find them:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

Note that NO characters are allowed before the declaration... not even spaces.

Could you remove the declaration altogether?

Kind regards

Steve
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

Re: The processing instruction target matching "[xX][mM][lL]" is not allowed.

#3

Postby Steve James » Thu Oct 26, 2017 8:44 am

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.
0 x


Who is online

Users browsing this forum: No registered users and 11 guests