代号一HTML解析

Codename One HTML parsing

我正在努力创建一个 Iphone 应用程序。我需要在 Codename One 上的标签或 Android.

上的 TextView 上显示网页的一部分

在Android中我使用JAVAjsoup

如何在代号一上实现此代码:

 Document  document = Jsoup.connect(url)
                    .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0")
                    .get();

            Elements element1=document.select("#pd_foto_fondo > div:nth-child(2)");
            String string1=ultact.text();

您可以使用 Codename One XML parser which can parse HTML as well and you can use the processing package 使用 xpath 搜索结果 XML/HTML。

Codename One 中内置的 XML 解析器并不严格,应该能够毫无问题地解析大多数 XML 文件。要获取文件进行解析,您可以使用 ConnectionRequest class,您还可以在其中设置用户代理。