Java库转义/清除XML? [英] Java library to escape/clean XML?
问题描述
< Tag>某事< / Tag> 8> 3 ,2< 3,...< Tag> something< / Tag>
我想清理输入,以便得到:
< Tag> something< / Tag> 8& gt; 3,2& lt; 3,...< Tag> something< / Tag>也就是说,转义这些特殊符号,例如<,>,然后保留有效的标签(<>$), code>< Tag> something< / Tag>
,注意,同样的情况)
你知道任何java图书馆做这个可能是一个xml / html解析器(虽然我不需要一个解析器,简单的干净的程序)
解决方案JTidy 是HTML语法检查器和漂亮的打印机。像非Java表哥一样,JTidy可以作为清理格式错误的HTML的工具
但是也可以与xml一起使用。这是不可思议的聪明,它可能适用于你。
I get some malformed xml text input like:
"<Tag>something</Tag> 8 > 3, 2 < 3, ... <Tag>something</Tag>"
I want to clean the input so to get:
"<Tag>something</Tag> 8 > 3, 2 < 3, ... <Tag>something</Tag>"
That is, escape those special symbols like <,> and yet keep the valid tags ("
<Tag>something</Tag>
, note, with the same case)Do you know of any java library to do this? Probably a xml/html parser? (though I don't really need a parser, simple a "clean" procedure)
解决方案JTidy is "HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML"
But it can also be used with xml. Check the documentation. It's incredible smart, it will probably work for you.
这篇关于Java库转义/清除XML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!