views:

635

answers:

2

I'm working with an xml node of the following structure:

<CF>
 <T>
  <TX>title</TX>
  <em>15:2:</em>
 </T>
 <KW>
  <TX>SOMETHING ELSE</TX>
 </KW>
 <!-- OTHER TAGS, SOME OF WHICH HAVE A <TX> CHILD -->
</CF>

Things work more or less as I expect in firefox, but I'm getting weird behavior in IE8. For example, the following gives me a jquery object of length 14:

jQuery("T TX", xmlDoc).length

where it should be only one (the "CF" tag contains only one "T" tag, which in turn contains only one "TX" tag).

Adding to the strangeness, if I remove the "T" from the selector, as in the following:

jQuery("TX", xmlDoc).length

I get FEWER, rather than an equal or greater number of results (the jquery object's length is 12).

So, the first question is: if there's only one TX tag, and it has only one "T" tag, why does jquery find 14 "TX" tags which are descendants of a "T"?

The second question is: if I simplify the selector, removing the "T", why do I get fewer, rather than more results?

Am I doing something wrong, or have I stumbled upon a bug?

A: 

There are 14 characters in "<TX>title</TX>". Since I don't know how many actual TX elements there are, I couldn't say if the 12 from the second query is the number of TX elements in the document.

Kind of crazy and off the wall...but perhapse the length property isn't returning what you think its returning?

jrista
Jrista, intersting theory (and impressive observation!) but "title" is just example text. In the real xml doc the text is longer.
morgancodes
lol...I had to try...it was the only non-obvious thing I could see. Any way you could post the full document? There might be more information that could be gleaned with more data...
jrista
+1  A: 

Perhaps you can try something like this:

jQuery('T', mydoc).find('TX').length

and see what happens

Pablo Fernandez