I am developing an android project. I am using dom parser to parse the xml file. Issue is my xml file contains html numbers like ½ (semicolon will come in the end of every char code)
for example
<quote>We “love” our nation</quote>
which is nothing but
<quot>We "love" our nation</quote>
I am not able to parse this html number in dom parse, when I try to get the node value, I am getting null.
开发者_C百科Can anyone tel me how to parse this html character codes?
or
How to convert this html char code as either text char code or unicode char set in my xml feed?
There is a very similar question here: Android decoding html in xml file
It seems the html characters break the DOM parser, so it is unable to get the string from the xml entity.
There is a HTML function to parse HTML in a string:
TextView tv = (TextView) findViewById(R.id.tv);
String s = <quote>We “love” our nation</quote>";
tv.setText(Html.fromHtml(s));
Outputs:
We "love" our nation
However it seems the DOM isn't getting the string to convert, so the following article maybe useful: Using XPATH and HTML Cleaner to parse HTML / XML
I have used xmlpullparser. Its working fine now. :)
精彩评论