Expand my Community achievements bar.

SOLVED

XML-110018 Error while parsing XML string

Avatar

Level 3

Dear All

We are facing an issue if I add '&' symbol in a text field while submitting a web form. if we are not adding the special character it works fine. 

XML parsing is a issue I feel, even the '&' is changing to <varSetName>test&amp;test</varSetName>. Not sure what is the issue, Please help me.

Below is the error while submitting,

We have found the script which is causing the issue. 

xtk.session.Write(insertxml);

Script:

var insertxml ="<Data_Collection xtkschema=\"xxx:Data_Collection\" Salutation= \"" + ctx.vars.varSalutation +"\" FIRST_NAME= \"" + ctx.vars.varFirstname +"\" LAST_NAME= \"" + ctx.vars.varLastname +"\" EMAIL= \"" + ctx.vars.varEmail +"\" PHONE= \"" + ctx.vars.varTelephone +"\" Creation_Date=\""+ formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S') +"\" Creation_Date_2=\""+ formatDate(getCurrentDate(),"%2D.%2M.%4Y") +"\" SetName= \"" + ctx.vars.varSetName +"\" Preis= \"" + ctx.vars.varPreis +"\" GueltigBis= \"" + ctx.vars.varGueltigBis +"\" _operation=\"insert\"></Data_Collection>";
xtk.session.Write(insertxml);

Error Message:

Unterminated entity reference, 'test' XML-110018 Error while parsing XML string '<__sessiontoken xsi:type='xsd:string'><' SOP-330011 Error while executing the method 'Write' of service 'xtk:persist|xtk:session'.

Please let me know if you need any details.

Thanks in advance

Ukender

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @ukender

 

Try this code.

 

var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema='xxx:Prospects_Data_Collection' Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis} _operation= 'insert' > <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);

 

 

Let me know if that works. 


     Manoj
     Find me on LinkedIn

View solution in original post

9 Replies

Avatar

Correct answer by
Community Advisor

Hello @ukender

 

Try this code.

 

var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema='xxx:Prospects_Data_Collection' Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis} _operation= 'insert' > <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);

 

 

Let me know if that works. 


     Manoj
     Find me on LinkedIn

Avatar

Level 3

Hi @Deleted Account, Thanks a lot  for the suggestion.. I have tried your suggestion but the below script but doesn't work for me. it failed in compilation.

 

The previous code works well, If I did not add '&' special characters in the text field. So could you please suggest me some workaround for why the '&' is not taking in the text field.

 

Tried Script:

var creationDate=formatDate(new Date(),'%4Y-%2M-%2D %2H:%2N:%2S');
var creationDate2=formatDate(getCurrentDate(),"%2D.%2M.%4Y");
var insertxml ="<Prospects_Data_Collection xtkschema="xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} Saugroboter200={ctx.vars.varSaugroboter200} Akkusauger={ctx.vars.varAkkusauger} Saugwischer={ctx.vars.varSaugwischer} Automatik_Elektroburste={ctx.vars.varAutomatik_Elektroburste} ContactEvents={ctx.vars.varEvents} Hartbodenduse={ctx.vars.varHartbodenduse} Fensterreiniger={ctx.vars.varFensterreiniger} Polsterburste={ctx.vars.varPolsterburste} Softduse={ctx.vars.varSoftduse} Flexoduse={ctx.vars.varFlexoduse} Teppichfrischer={ctx.vars.varTeppichfrischer} Matratzenreinigung={ctx.vars.varMatratzenreinigung} Varioduse={ctx.vars.varVarioduse} Elektrosaugschlauch={ctx.vars.varElektrosaugschlauch} Akku_Staubsauger={ctx.vars.varAkku_Staubsauger} Saugroboter300={ctx.vars.varSaugroboter300}> </Product_interest> <address STREET={ctx.vars.varStreet} HNUM={ctx.vars.varHousenum} POST_CODE={ctx.vars.varPostalcode} CITY={ctx.vars.varCity} STORE={ctx.vars.varStorename} VORWERK_EMAIL={ctx.vars.varStoreEmail}> </address> <Permissions ContactKobold={ctx.vars.varContactKobold} ContactKoboldBetr={ctx.vars.varContactKoboldBetr} Privacy_Accept={ctx.vars.varAccept}</Permissions> </Prospects_Data_Collection>";
xtk.session.Write(insertxml);

 

Error:

 

JST-310000 Error while compiling script 'webApp_Prospects_Data_Collection_New_17_06_2019__preview' line 2610: missing ; before statement (line='var insertxml ="<Prospects_Data_Collection xtkschema="xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBo' token='xxx:Prospects_Data_Collection" Salutation={ctx.vars.varSalutation} FIRST_NAME={ctx.vars.varFirstname} LAST_NAME={ctx.vars.varLastname} EMAIL={ctx.vars.varEmail} PHONE={ctx.vars.varTelephone} Creation_Date={creationDate} Creation_Date_2={creationDate2} SetName={ctx.vars.varSetName} Preis={ctx.vars.varPreis} GueltigBis={ctx.vars.varGueltigBis}_operation= "insert" /> <Product_interest Kobold={ctx.vars.varKobold} Bodenstaubsauger={ctx.vars.varBodenstaubsauge} Handstaubsauger={ctx.vars.varHandstaubsauger} ').
SCR-160032 Javascript&colon; error while compiling script 'webApp_Prospects_Data_Collection_New_17_06_2019__preview'.

Avatar

Community Advisor
According to the error" missing ; before statement", semicolon is missing in your code. Could you please check for that?

     Manoj
     Find me on LinkedIn

Avatar

Level 3

Hi @Deleted Account, Yes Manoj I have verified, I have the semi colon where ever it is necessary.

I have tried to keep semi colon ; in each element end tag as well but it didn't give me the solution,

For example I have given the ; in </address> .

Avatar

Community Advisor
Updated the code in the answer removed "/" from "_operation= "insert" /"

     Manoj
     Find me on LinkedIn

Avatar

Level 3
Hi @Deleted Account, Thanks for the effort. sorry to say this still I am facing the same issue, I have tried multiple option placing the insert in "" ,'' and without any also tried with combo against the /> and >. Nothing has turned around

Avatar

Community Advisor
Can you share the full code from the javascript activity?

     Manoj
     Find me on LinkedIn

Avatar

Administrator

Hi @ukender ,

 

Were you able to resolve this?

 

 



Sukrity Wadhwa