How to tell if a string is xml?

后端 未结 7 1699
北荒
北荒 2021-01-11 10:44

We have a string field which can contain XML or plain text. The XML contains no header, and no root element, i.e. is not well formed.

We need t

7条回答
  •  春和景丽
    2021-01-11 11:14

    One possibility is to mix both solutions. You can use your redact method and try to load it (inside the if). This way, you'll only try to load what is likely to be a well-formed xml, and discard most of the non-xml entries.

提交回复
热议问题