Java/Android HTML自定义标记解析器
我正试图找出一种方法来解析html文件,其中包含表单中的自定义标记:Java/Android HTML自定义标记解析器,java,android,html-parsing,jsoup,jericho-html-parser,Java,Android,Html Parsing,Jsoup,Jericho Html Parser,我正试图找出一种方法来解析html文件,其中包含表单中的自定义标记: [custom tag="id"] 下面是我正在处理的一个文件的示例: <p>This is an <em>amazing</em> example. </p> <p>Such amazement, <span>many wow.</span> </p> <p>Oh look, a wild [custom tag="
[custom tag="id"]
下面是我正在处理的一个文件的示例:
<p>This is an <em>amazing</em> example. </p>
<p>Such amazement, <span>many wow.</span> </p>
<p>Oh look, a wild [custom tag="amaze"] appears.</p>
We need maor embeds <a href="http://youtu.be/F5nLu232KRo"> bro
其中,上述列表中的元素包含:
文本:
<p>This is an <em>amazing</em> example. </p>
<p>Such amazement, <span>many wow.</span> </p>
<p>Oh look, a wild [custom tag="amaze"] appears.</p>
We need maor embeds
[custom tag="amaze"]
<a href="http://youtu.be/F5nLu232KRo">
appears.</p>We need maor embeds
链接:
<p>This is an <em>amazing</em> example. </p>
<p>Such amazement, <span>many wow.</span> </p>
<p>Oh look, a wild [custom tag="amaze"] appears.</p>
We need maor embeds
[custom tag="amaze"]
<a href="http://youtu.be/F5nLu232KRo">
appears.</p>We need maor embeds
Jsoup很棒,它非常适合HTML。问题是我无法定义带有开头“[”和结尾“]”的自定义标记。如果我错了,请纠正我好吗
同样像Jsoup一样,Jericho工作得很好..除了定义自定义标记。您可以使用“我认为您不会绕过这里的手工工作。通过jsoup和正则表达式的组合,您应该可以得到它。可能有用:您可以尝试使用jsoup和XML解析器:Document doc=jsoup.parse(html,baseUri,Parser.xmlParser());[custom tag=“amaze”]
在某个地方关闭吗?不,它不会关闭。它只是[custom tag=”amaze“]我当前的解决方案是使用正则表达式替换每个[custom tag=“amaze”],以便Jsoup可以解析,但我希望避免字符串替换,因为自定义标记包含的内容可能相当大。