xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abraham Rodriguez Mota" <abraham.r...@gmail.com>
Subject Re: Comparing strings
Date Wed, 10 Sep 2008 14:59:07 GMT
Thanks Thomas. You are right it was the problem.

Cheers

Abraham

On Wed, Sep 10, 2008 at 12:24 PM, <thomas.deweese@kodak.com> wrote:

>
> 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.
>

Mime
View raw message