Store html tags in xml Store html tags in xml xml xml

Store html tags in xml


Enclose your HTML in a CDATA section so it doesn't get treated as part of your XML, but instead just normal text:

<result><![CDATA[    <body><font size="2px" face="arial">Hello World</font></body>]]></result>

Update

Your problem is probably here:

sb.append("<result>\r\n");    sb.append("<body>");    String tmpText = html2text(text.toString());        sb.append("<![CDATA[<body>");        sb.append(tmpText);        sb.append("</body>]]>");    sb.append("</body>\r\n");sb.append("</result>\r\n");

Notice the sb.append("<body>"); and sb.append("</body>\r\n"); lines surrounding your CDATA section, they're probably causing the problem with your XML not being read correctly. Maybe you should remove those two lines so it looks like this:

sb.append("<result>\r\n");    String tmpText = html2text(text.toString());    sb.append("<![CDATA[<body>");    sb.append(tmpText);    sb.append("</body>]]>");sb.append("</result>\r\n");