001package org.hl7.fhir.utilities.xhtml;
002
003import lombok.extern.slf4j.Slf4j;
004
005@Slf4j
006public class XhtmlUtils {
007
008  public static String convertHtmlToText(String source, String desc) {
009    try {
010      XhtmlDocument doc = new XhtmlParser().parse(source, "html");
011      return doc.getDocumentElement().allText();
012    } catch (Exception e) {
013      // todo - should we try another way?
014      log.error("XHTML content could not be parsed from "+desc, e);
015      log.error(source);
016      return "Unparseable HTML Source ("+e.getMessage()+")";
017    }
018  }
019
020}