Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: javascript parentNode

From: "VK" <schools_ring@-----.--->
To: NULL
Date: 4/2/2006 4:13:00 AM


anupamjain@g... wrote:
> An interesting thing is happening. My table doesnt have 'TBody', but
> the elem.parentNode.tagName is returning 'TBody' where elem refers to
> the 'tr' tag.
>
> Shouldnt it be returning 'table' ?

The TBODY element is exposed for all tables, even if the table does not
explicitly define a TBODY element. (True for IE at least => 90% of
UA's)

Same for HTML (=> document.documentElement) It is actually an
obligatory element for HTML documents, unlike say <body>.

> Is there a way to tell javascript not to be
> intelligent? (because I am building an xpath and I want to extract the
> exact xpath from the real-world-html-document)

JavaScript has nothing to do with it. The "intelligence" is
demonstarated by browser DOM parser. You seem mixing two very different
issues here: i) the source HTML code representing a page and ii) DOM
tree built on the basis of this source code.

You can retrieve any HTML source by using say responseText from an
ajaxoid and study it line by line. Here it is not important how many
rude mistakes is made in the layout, because it is just plain text for
you.

But with xpath and DOM methods you are dealing with the parsing
*results*, and these results can be far away of what is written in the
code. More poorly written code -> more efforts UA needs to spend to
build some reasonnable DOM tree -> more this DOM tree may differ from
the one intended in the obscured author's mind.

>From the other side without DOM tree ready you cannot work with it. So
for xpath you just have to drop the idea to study the source and
concentrate on source parsing results:- bearing in mind that these
results may differ significally from one browser to another.

An alternative solution would be only to write your very own HTML
parser and feed the source into it over responseText.

P.S. It is actually strange that you are worring about such small and
easy to fix issues. I would expect you being nocked by phantom nodes on
tags' borders in W3C-victimized browsers (cannot say "W3C-compliant" in
this particular case). Either you already solved it or did not noticed
yet.



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent