How can I escape text for an XML document in Perl?

前端 未结 9 1187
长发绾君心
长发绾君心 2021-01-01 06:53

Anyone know of any Perl module to escape text in an XML document?

I\'m generating XML which will contain text that was entered by the user. I want to correctly handl

9条回答
  •  情深已故
    2021-01-01 07:13

    I am not sure why you need to escape text that is in an XML file. If your file contains:

    x < y
    

    The file is not an XML file despite the proliferation of angle brackets. An XML file must contain valid data meaning something like this:

    x < y
    

    or

    
    

    Therefore, either:

    1. You are not asking for escaping data in an XML file. Rather, you want to figure out how to put character data in an XML file so the resulting file is valid XML; or

    2. You have some data in an XML file that needs to be escaped for some other reason.

    Care to elaborate?

提交回复
热议问题