Hi I have a not valid xml "<samplexml> my text with & or < chars </samplexml>"
I want to convert it to a valid XML, replacing the special chars in text. So result will be:
"<开发者_开发技巧samplexml> my text with & ; or < ; chars </samplexml>"
Do anyone knows some lib in Java that already solves this problem?
thx
Don't think of it as "not valid XML". Think of it as "not XML". If you're given some input text, you will have to write a parser for it. It's not XML, so you can't use an XML parser, you will have to write your own. Before you can do that, you need to define the syntax of the language that you want to parse. It wouldn't do any harm to do that by taking the grammar of XML, and using that as a basis for writing a grammar for the non-XML language that you want to accept.
精彩评论