简体   繁体   English

如何在Java或JSP中删除XML元标记

[英]How to remove XML meta tags in java or jsp

i am having a xml something looks like this 我有一个XML,看起来像这样

<?xml version='1.0' encoding='utf-8'?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><content></content>

i just want to extract the content alone,i am expecting something like this. 我只想单独提取内容,我期望这样的事情。

<content></content>

i know String replace is a solution but it changes every time. 我知道字符串替换是一种解决方案,但每次都会更改。

Thanks. 谢谢。

使用jsoup

String extracted = Jsoup.parse(xml).getElementsByTag("s:body").first().html();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM