cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Node References

cedorfm
Champ in-the-making
Champ in-the-making
Hello,

I'm comparing two node references (children[x] and childByNamePath) using the equality operator. When I print the two node references they are an exact match.

   
for (var i = 0; i < container.children.length; i++)
   {
      if (container.children[0] == nodeEnglish)
      {
         nodeContent = nodeEnglish.content;
      }
      else
      {
         nodeContent = "Criteria not met.";
      }
   }
   model.text = nodeContent;

The result of the script is always "Criteria not met.", when it should be returning the contents of the document.
Technically this SHOULD be possible.  :? 

Thanks in advance for your help.

Matt
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
Make sure you're comparing two strings and not two different types.

Use either String(…) or …toString()

Thanks,
Mike

cedorfm
Champ in-the-making
Champ in-the-making
I knew I was comparing different datatypes, which is why I used toString() on both node references, however this did not work. I used String() on just the array type and now it works fine!  Smiley Very Happy, even though the output is now different when comparing the two. Wierd but it works!

Thanks again Mike for your help.