Renato R. (RRaver) wrote:
**Hi guys,
I need a way to return the full node of a XPATH result, but I don't know
how or even if it is possible.
For example, if I try something like this,
<a href="http://www.site.com <http://www.site.com>">This is a Link</a>
.......
<script>
.....
var blabla = document.evaluate("//a", document, null, 7,null);
blabla.snapshotItem(0) will return "This a Link" and
blabla.snapshotItem(0).href will return "http://www.site.com" and so
on... But what I really need is a way to return exactly "<a
href="http://www.site.com">This is a Link</a>" that is the matched node.
Is possible to do it? I've tried somethings like nodeValue e things like
that but none of them worked.... Someone can help-me?
Thanks for the attention
You do get the node. The simple fact that the snapshotItem does have an
href property tells you that it is a well set up HTMLAnchorElement.
Verify that with
blabla.snapshotItem(0) instanceof HTMLAnchorElement. See
http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/ecma-script-binding.html,
the very last item, after the long grey box. This tells you about string
conversions for anchor elements.
And you should surely not get "This is a Link" as string value of the
anchor element, bug "http://www.site.com".
Or are you not talking about nodes but do you want the source for that
node? You won't get it, but you can serialize it. As we don't support
outerHTML, the best thing you can do (if you're an extension) is to use
a document encoder and a range with your anchor element in it.
parentNode.innerHTML is going to give you siblings, too, so that won't
work right.
Axel
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners