From an XML file displayed in a WebView, I would like to be able to select text with the mouse, and when a button is pressed, add a unique XML tag to that selection.
Sample XML file fragment:
<p>
some text that is in this paragraph
</p>
If I select "that is" from the above, and press the button, it should result in:
<p>
some text <x id="foo">that is</x> in this paragraph
</p>
where <x>
is a special tag I will use for my own purposes. It might have attributes, like an id or something.
I see that I can use bits of JS code to gather info about the HTML tags and locate the selected text in a given tag, but I don't know how to get an "absolute" location. Nor do I know how to inject the XML tag into the XML file. Or maybe I should treat it as an HTMLEditor or something? I just don't want the user to be able to change the XML file except in this particular way.
Any ideas? Very appreciated.