Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

XML-110018 Error while parsing XML string

ukender
Level 3
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
Manoj_Kumar_
Correct answer by
Community Advisor
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. 

View solution in original post

0 Replies
Manoj_Kumar_
Correct answer by
Community Advisor
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. 

View solution in original post

ukender
Level 3
Level 3

Hi @manoj, 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'.

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

Hi @manoj, 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> .

Manoj_Kumar_
Community Advisor
Community Advisor
Updated the code in the answer removed "/" from "_operation= "insert" /"
ukender
Level 3
Level 3
Hi @manoj, 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 😞
Manoj_Kumar_
Community Advisor
Community Advisor
Can you share the full code from the javascript activity?
Sukrity_Wadhwa
Employee
Employee

Hi @ukender ,

 

Were you able to resolve this?