XML-110018 Error while parsing XML string

Avatar

Avatar
Validate 1
Level 1
ukender
Level 1

Likes

0 likes

Total Posts

33 posts

Correct reply

1 solution
Top badges earned
Validate 1
Give Back
Applaud 5
Affirm 1
View profile

Avatar
Validate 1
Level 1
ukender
Level 1

Likes

0 likes

Total Posts

33 posts

Correct reply

1 solution
Top badges earned
Validate 1
Give Back
Applaud 5
Affirm 1
View profile
ukender
Level 1

16-07-2020

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile

Avatar
Affirm 100
MVP
_Manoj_Kumar
MVP

Likes

117 likes

Total Posts

329 posts

Correct reply

102 solutions
Top badges earned
Affirm 100
Validate 1
Contributor
Ignite 1
Shape 1
View profile
_Manoj_Kumar
MVP

16-07-2020

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. 

ukender

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
According to the error" missing ; before statement", semicolon is missing in your code. Could you please check for that?
ukender

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
Updated the code in the answer removed "/" from "_operation= "insert" /"
ukender
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
Can you share the full code from the javascript activity?
ukender
Yes Please check your inbox. Thanks!

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

157 likes

Total Posts

926 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile

Avatar
Give Back 50
Employee
Sukrity_Wadhwa
Employee

Likes

157 likes

Total Posts

926 posts

Correct reply

35 solutions
Top badges earned
Give Back 50
Validate 1000
Validate 500
Validate 250
Validate 100
View profile
Sukrity_Wadhwa
Employee

22-07-2020

Hi @ukender ,

 

Were you able to resolve this?