Best way to convert xml to have CDATA around text (in java)

前端 未结 4 586
[愿得一人]
[愿得一人] 2021-01-23 02:14

I have a weird requirement where I need to take some xml and re-write it so that the text nodes are wrapped in CDATA (this is for a client that won\'t allow normal escaping).

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-23 02:48

    Taking premade xml and parsing (with an xml parser) it is just going to make the parser choke on the unescaped characters. The only solution I can think of is to make your own tag soup parser to parse it, modify and dump it back to xml.

提交回复
热议问题