如果文本有HTML <b>标签,VTD-XML不能vn.getText()?

时间:2018-05-04 15:09:18

标签: xml xml-parsing vtd-xml

XML看起来像这样:

<resources>
  <string name="SignInPrompt">Sign in with <b>%1$s</b></string>
</resources>

导航看起来像这样:

if (vnCurrent.toElement(VTDNav.FIRST_CHILD, "string")) {
while (true) {
    def currentStringIndex = vnCurrent.getText()
    // ^^^^ this is always -1 when it hits the strings with <B>
    def currentStringValue = (currentStringIndex != -1) ? vnCurrent.toRawString(currentStringIndex) : ""

    if (!vnCurrent.toElement(VTDNav.NEXT_SIBLING)) break
}

我正在尝试抓取XML文本来对其进行处理。 我们不编码

<B> as &lt;B&gt;

因为Android了解如何在从资源中读取字符串时正确转换粗体字符串w / o通过单独的fromHtml调用。

0 个答案:

没有答案