2011-01-10 6 views
0

건물중인 Android 앱에 Google 도서 API를 사용하고 있습니다. 이것은 XML의 샘플RSS 피드 용 DOM 파서를 사용하여 Android에서 HTML 항목을 파싱

<dc:description>This trilogy includes &amp;quot; The Hitchhiker&amp;#39;s Guide to the Galaxy&amp;quot; , &amp;quot; TheRestaurant at the End of the Universe&amp;quot; , &amp;quot; Life, Universe and Everything&amp;quot; and &amp;quot; So Long ...</dc:description> 
<dc:format>590 pages</dc:format> 
<dc:format>book</dc:format> 

파일입니다 그리고 이것은 내가 설명 HTML.fromHtml을 사용할 때 문제가

if (entry.getElementsByTagName("dc:description").item(0) != null) { 
    Element d = (Element) entry.getElementsByTagName("dc:description") 
     .item(0); 
    b.setDescription(d.getFirstChild().getNodeValue()); 

} 

을 추출하기 위해 사용하고 코드의 일부분이다 (STR) 그 첫 번째 HTML 엔티티의 텍스트를 차단 기능 (그래서이 예제에서는 단순히

이 부작 포함 말한다

는, 즉

This trilogy includes &quot; The Hitchhiker&#39;s Guide to the Galaxy&quot; , &quot; TheRestaurant at the End of the Universe&quot; , &quot; Life, Universe and Everything&quot; and &quot; So Long ... 

내가 수동 (응용 프로그램 HTML.fromHtml이를 추가하는 경우)의 작품을 작품을 좋아하고 적어도 이스케이프 문자로 문자열을 보여줍니다 안드로이드의 외부 나도 같은 코드를 실행하면 좋아, 그래서 문제는 안드로이드의 파서 구현입니다.

비슷한 문제는 Android decoding html in xml file입니다. 나는 공장의 유효성 검사를 false로 설정하려고 시도했다. RSS 피드이기 때문에이 루트에서 HTML 루트 요소를 선언 할 수 없다.

답변

0

Google에서 설명 데이터를 가져 오지 못했지만 문서 요소에 normalize()를 실행하여 문제가 해결 될 수 있다고 생각합니다. 다른 API와 비슷한 문제가 있었지만 해결되었습니다.

+0

동일한 문제가 있습니다. "normalize()"의 의미를 설명해 주시겠습니까? –