33
Views
5
Comments
XML special char problem
Question

Hi guru's!

I have a question I have a name like test'a and when I use the xml component to generate a xml the ' is shown as a question mark. I need tot to auto generate something like ' is there something to use to do this automatically? 

Kind regards.

2023-12-16 19-57-03
Sanjay Kushwah

hii @freek,

you need to escape it using the apostrophe entity ('). This will ensure that the character is interpreted correctly by XML parsers and avoid the question mark issue. 


In this example, the entity is used to represent the apostrophe.

When you parse or display this XML, the entity will be interpreted as an apostrophe, and you will see "test'a" as the output.

kind regards,

Sanjay Kushwah 

UserImage.jpg
freek

Thanks only the data is stored in the database like '  so is there a function that I can use when I add a value to the xml that I escape it?

2023-12-16 19-57-03
Sanjay Kushwah

hii @freek,

in outsystems we have inbuild replace() function you can use it. and replace ' (apostophe) with XML entity that i mentioned, before putting into XML file.


kind regards,

Sanjay Kushwah

UserImage.jpg
Alexandre Yip

Hi free, 

You can use replace built in Action to replace all the occurrences of reserved xml characters by the correct one. 

Provide then the result to the component. 

Hope that it helps you 

UserImage.jpg
freek

So when I export the xml it now gives: dsA�S  so the ' is replaced by �. So the only solution is to do a replace on all possible strange chars before putting them in the XML? Is there maybe a XML format fix that I need to set it to UTF8 or something and there fore it will work because I want to prevent to make a function to escape all by hand. Is there else maybe a forge component to use for this?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.