android - 我想在 WebView 中显示一个 XML 标签 <Cat_Desc> 但它也有 HTML 标签

标签 android html-parsing xml-parsing android-webview

我必须从 xml 中解析数据。这是我的 xml- 或者它的 url 是:http://mobileecommerce.site247365.com/admin/catdata.xml

  <Cat_Name>News for the day</Cat_Name>
    <Cat_Desc>
    <div style="text-align: center;"><span class="Apple-style-span" style="font-weight: normal; font-size: medium; "><img src="http://mobileecommerce.site247365.com/admin/assetmanager/images/gns_header.jpg" alt="" align="middle" border="1px" height="90" width="550"></span></div><span class="Apple-style-span" style="color: rgb(105, 105, 105); font-family: Verdana; font-size: 13px; font-weight: normal; "><br><div style="text-align: center;">Yes we are coming at E & I? Are you?</div></span><br><h1 style="font-weight: bold; "><span style="font-family: Verdana; font-size: 14pt; ">News for the day...</span></h1><span style="color: rgb(105, 105, 105); "><span style="font-family: Tahoma; font-size: 10pt; ">Template Mobile Sites for IC: <a href="http://icmobilesite.vidushiinfotech.net/">http://icmobilesite.vidushiinfotech.net/</a></span><br><span class="Apple-style-span" style="font-family: Tahoma; font-size: 13px; color: rgb(105, 105, 105); ">Promotional valid till 30 Sept 2011: MOBILE WEBSITE (Base Product Mobile CMS) for JUST $159<br></span></span><br><span style="font-family: Tahoma; font-size: 10pt; color: rgb(105, 105, 105); ">Mobile Template link: </span><a href="http://newsletter.vidushiinfotech.net/Mobilesite/"><span class="Apple-style-span" style="font-size: 15px; font-family: Calibri, sans-serif; color: rgb(105, 105, 105); ">http://newsletter.vidushiinfotech.net/Mobilesite/</span><br></a><span style="font-size: 10pt; font-family: Tahoma; "><span style="font-size: 10pt; "><br><span style="color: rgb(105, 105, 105); ">With the promotion on Business Edge and eFusion still running successful in e market place - $ 499</span><br><span style="color: rgb(105, 105, 105); ">Check out some of the latest site launch on: </span><br><br><span style="color: rgb(105, 105, 105); font-weight: bold; ">http://www.randallcontracting.co.uk/Pages/Default.aspx </span><br><br><span style="color: rgb(105, 105, 105); font-size: 10pt; "><span style="font-weight: bold; ">Category</span>: Building & Construction</span><br></span><br></span><div style="color: rgb(105, 105, 105); text-align: left; "><span style="font-size: 10pt; font-family: Tahoma; ">Description: WELCOME TO RANDALL CONTRACTING Randall Contracting is a family-run contracting SME which has been servicing London and the South East since 1956. Working closely with our Clients and external Design Consultants, we place great emphasis on a safe, positive, practical and common sense approach to our projects. Our delivery methods have resulted in an extensive volume of repeat business from both Private and Public Sectors. Safety and Environmental concerns are a high priority on all our contracts and we continually strive to source innovative working methods and solutions. Our equipment is regularly updated and maintained to ensure minimal environmental impact.</span><br><br></div><span style="color: rgb(105, 105, 105); font-weight: bold; font-family: Tahoma; "><span style="font-size: 10pt; "><br></span></span><br>
        </Cat_Desc>

我为第一个 cat_name 添加了一个 snap。在 webview 或 android 中的任何其他 View 中上传整个 cat_description 的任何方式,或者我需要一个一个地解析并一个一个地显示。

这张图片有标签数据

任何帮助将不胜感激。提前致谢

最佳答案

伙计们,我得到的答案是,我们只需将整个 XML(带有 HTML 标签) 保存到 String 中,然后将该字符串传递给 WebView 。它将显示您的所有数据。这是因为 WebViews 只理解 HTML 或 XML,所以当我们将我们的 HTML 字符串以 XML 格式传递给它们时。它理解并显示我们想要的内容。

关于android - 我想在 WebView 中显示一个 XML 标签 <Cat_Desc> 但它也有 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7817863/

相关文章:

Android 迁移到 appcompat v7 导致错误 : Attribute "color" has already been defined

android - 从在单独进程中运行的服务访问变量

Python:使用 Beautifulsoup 从 html 中获取文本

javascript - 访问 JavaScript 在运行时创建的元素 (document.write)

javascript - 使用 xml2js 解析 xml 的 Node

java - 使用Jsoup解析Xml

java - OS Mavericks 中的 ANT 命令出错

java - 使用 BaseAdapter 重新排序和重复 ListView 项目

html - 任何主流浏览器是否都有内置的 HTML 验证器?

PHP - 用重音符号解析 xml