rangy反序列化不适用于webview android

rangy反序列化不适用于webview android,android,serialization,rangy,Android,Serialization,Rangy,我正在尝试在我的一个使用webview的Android项目中为epub阅读器制作“Highlighter”。 我正在使用Rangy获取所选文本。 serialize函数在从以下示例HTML中选择文本后为我提供此值: 2/5/3/5/1/2:0,13/5/3/5/1/2:24 我把它存储在数据库中。当用户返回此页面时,我正在检索相同的选择并尝试反序列化,但反序列化函数抛出以下错误: Error in Rangy Serializer module: deserializePosition fai

我正在尝试在我的一个使用webview的Android项目中为epub阅读器制作“Highlighter”。 我正在使用Rangy获取所选文本。 serialize函数在从以下示例HTML中选择文本后为我提供此值:

2/5/3/5/1/2:0,13/5/3/5/1/2:24
我把它存储在数据库中。当用户返回此页面时,我正在检索相同的选择并尝试反序列化,但反序列化函数抛出以下错误:

Error in Rangy Serializer module: deserializePosition failed: node <DIV>[7] has no child with index 13, 0
Rangy序列化程序模块中出现错误:反序列化位置失败:节点[7]没有索引为13的子节点,0 我明白为什么会发生这种事?? 即使我尝试使用XPath做同样的事情,但仍然存在相同的问题

<html>
<head>
<script></script>
</head>
<body>
<div id="mainpage" class="highlighter-context">
<div>       Some text here also....... </div>
<div>      Some text here also.........</div>
<div>
  <h1 class="heading"></h1>
  <div class="left_side">
<ol></ol>
<h1></h1>
<div class="text_bio">
In human beings, height, colour of eyes, complexion, chin, etc. are 
some recognisable features. A feature that can be recognised is known as 
character or trait. Human beings reproduce through sexual reproduction. In this                
process, two individuals one male and another female are involved. Male produces   
male gamete or sperm and female produces female gamete or ovum. These gametes fuse 
to form zygote which develops into a new young one which resembles to their parent. 
During the process of sexual reproduction 
</div>
  </div>
  <div class="righ_side">
  Some text here also.........
  </div>
  <div class="clr">
    Some text here also.......
  </div>
</div>
</div>
</body>
</html>

这里的一些文字也。。。。。。。
这里的一些文字也。。。。。。。。。
人类的身高、眼睛的颜色、肤色、下巴等都很重要
一些可识别的特征。可以识别的功能称为
性格或特征。人类通过有性繁殖繁殖。在这个
在这一过程中,涉及到两个人,一男一女。雄性产品
雄性配子或精子,雌性产生雌性配子或卵子。这些配子融合在一起
形成合子,发育成与父母相似的新的年轻合子。
在有性生殖过程中
这里的一些文字也。。。。。。。。。
这里的一些文字也。。。。。。。

任何猜测???

您可能正在使用以下选项:

highlighter.highlightSelection();
rangy.serializeSelection();  
如果在序列化之前运行
highlightSelection
,它将无法工作。 这是因为高亮显示实际上是在标记中包装文本,这意味着DOM被操纵

在原始DOM上反序列化显然行不通。 尝试更改命令的顺序,以便先序列化,然后才使用高亮显示

正确的顺序:

rangy.serializeSelection();    
highlighter.highlightSelection();