开发者

Escaping special characters in User Input in IzPack Installer

开发者 https://www.devze.com 2023-01-27 12:08 出处:网络
I have an IzPack installer that takes in a lot of User Inputs and substitut开发者_Go百科es them in an XML file. This XML file is actually the configuration file for my application.

I have an IzPack installer that takes in a lot of User Inputs and substitut开发者_Go百科es them in an XML file. This XML file is actually the configuration file for my application.

There is a major problem that I have hit and I cant move on from it.

In the Input fields (in the installer) user can enter any text and also special characters like & # % ' etc. These special characters messes up my XML file as they are no allowed in the XML syntax and needs to be escaped. for example for & one would need & So far I have been asking the user to do this, as in escape the special characters themselves, but thats now working either.

Is there a way to have this done automatically? I really need a solution fast.

I am using IzPack V 4.1


You should use a proper XML Api (SAX, DOM) to generate the XML file, this will apply the correct encoding automatically. This may look more complicated first but guarantees that a well formed, syntactically correct file is written.

Searching for JAXP should give you a proper starting point.

0

精彩评论

暂无评论...
验证码 换一张
取 消