0

In my application I do parsing xml and output the data in the required components on the phone screen, but there is a problem in that some of the data in the database stored in the form of html is as headers and tables. In PHP when the browser opens, they are displayed correctly, but I also wanted to display in my android application.

This is something similar to the forum. A list of messages which can be a table or a text. I think the use WebView not rational. Maybe there is some sort of Components to display html in android except WebView?

The Heist
  • 1,444
  • 1
  • 16
  • 32
Proger Progerov
  • 175
  • 1
  • 1
  • 8

1 Answers1

0

In Your Xml parser class create method.

public String stripHtml(String html) {
    html = html.replaceAll("<(.*?)\\>", " ");// Removes all items in
                                                // brackets
    html = html.replaceAll("<(.*?)\\\n", " ");// Must be undeneath
    html = html.replaceFirst("(.*?)\\>", " ");// Removes any connected item
                                                // to the last bracket
    html = html.replaceAll("&nbsp;", " ");
    html = html.replaceAll("&amp;", " ");
    html = html.replaceAll("\\<[^>]*>", "");
    return html;

}

And call that method in.

public final String getElementValue(Node elem) {
    Node child;
    if (elem != null) {
        if (elem.hasChildNodes()) {
                 return stripHtml(child.getNodeValue());
         }
    }

} It's working for me to show some html data from xml.

Jay Rathod
  • 11,131
  • 6
  • 34
  • 58