Unicode(0xb) error while parsing an XML file using Stax

后端 未结 3 484
半阙折子戏
半阙折子戏 2021-01-18 20:38

While parsing an XML file Stax produces an error:

Unicode(0xb) error-An invalid XML character (Unicode: 0xb) was found in the element content of the d

3条回答
  •  没有蜡笔的小新
    2021-01-18 21:05

    Whenever invalid xml character comes xml, it gives such error. When u open it in notepad++ it look like VT, SOH,FF like these are invalid xml chars. I m using xml version 1.0 and i validate text data before entering it in database by pattern

    Pattern p = Pattern.compile("[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD\u10000-\u10FFF]+");
    retunContent = p.matcher(retunContent).replaceAll("");
    

    It will ensure that no invalid special char will enter in xml

提交回复
热议问题