Jeyasithar
Jeyasithar

Reputation: 535

How to Parse MIME without multiple parts in it

I need <xml>__content__</xml> part from the following response string in java

Content-Type: application/xml; charset=UTF-8; name=response_xml<xml>...</xml>

Upvotes: 0

Views: 96

Answers (1)

MihaiC
MihaiC

Reputation: 1583

EDIT


Now that I understand what you need, you can use a simple regex to extract the text between the tags <xml> and </xml>


public static void main(String[] args) {
    String a="Content-Type: application/xml; charset=UTF-8; name=response_xml<xml>content</xml>";
    final Pattern pattern = Pattern.compile("<xml>(.+?)</xml>");
    final Matcher matcher = pattern.matcher(a);
    matcher.find();
    System.out.println(matcher.group(1));
}

Upvotes: 0

Related Questions