Hi Abraham,

Abraham Rodriguez Mota wrote on Sep 08, 2008:

> I am trying to compare two strings but the comparison operator always
> returns false. I printed the values using the alert function and the
> strings are read properly but the result is always false even when
> they are equal.

    My suspicion is that there is a whitespace difference.  This is
very common when you retrieve things from the DOM (as you are
doing).

> function updateConnections(targetElement){
> //Reading custom metadata, name space xxx
> var relation=targetElement.getElementsByTagNameNS(xxx,'rel');
> var elementID;
> 
> var currentId=relation.item(0).firstChild.nodeValue;

    Since this is the text content of a DOM element it's quite often
the case that it has a trailing newline.

> var updateRelation=relationsGroup.getElementsByTagName('line');
> 
> if(updateRelation.length>0){
> 
> for(var i=0;i<updateRelation.length;i++){
> 
> elementID=updateRelation.item(i).getAttribute('id');
> //variable's content change
> alert(elementID +" " + currentId+ "   ");

    I would suggest rewriting this as:

         alert("'" + elementID +"' '" + currentId+ "'");

    Then you can see the real contents of the strings.

Reply via email to