[jdom-interest] Looping through attributes

Bashiro bashiro at myway.com
Tue Jan 22 12:59:40 PST 2008



Thanks again Mike!
I am trying to get the value of the attr and not the attr itself.
I have a list of domains and the corresponding email adresses.
So when I get the "domain" as "attr" then get the corresponding value (that is:the domain name itself entered by the user).
and then display the domain and email address.

So if I use;
 if (att == null) {
display message;
}
it displays nothing



Bashiro
Drammen-Norway


 --- On Tue 01/22, Michael Kay < mike at saxonica.com > wrote:
From: Michael Kay [mailto: mike at saxonica.com]
To: bashiro at myway.com, jdom-interest at jdom.org
Date: Tue, 22 Jan 2008 19:08:19 -0000
Subject: RE: [jdom-interest] Looping through attributes

You surely don't want JDOM to display the message, you want to do ityourself.Isn't it just   Attribute att = element.getAttribute(name);  if (att == null) {    display message;  }or have I missed the point?Michael Kayhttp://www.saxonica.com/ > -----Original Message-----> From: jdom-interest-bounces at jdom.org > [mailto:jdom-interest-bounces at jdom.org] On Behalf Of Bashiro> Sent: 22 January 2008 17:53> To: jdom-interest at jdom.org> Subject: RE: [jdom-interest] Looping through attributes> > > Thanks for the mail.> And thanks for warning me about the else clause.> Do you have any suggestions on how to let jdom display a > message when the attribute is not dound ?> > Thanks> Bashiro> Drammen-Norway> >  --- On Tue 01/22, Michael Kay < mike at saxonica.com > wrote:> From: Michael Kay [mailto: mike at saxonica.com]> To: bashiro at myway.com, jdom-interest at jdom.org> Date: Tue, 22 Jan 2008 10:13:31 -0000> Subject: RE: [jdom-interest] Looping through attributes> > I can't see why you aren't using 
getAttribute() to get the > attribute byname, which would surely be much simpler. But > your actual bug is that youare executing the "else" code > ("Domain does not exist") once for everynon-matching > attribute (it's inside the while loop). A dangling else > bug.Take more care over indentation in future.Michael > Kayhttp://www.saxonica.com/> -----Original Message-----> > From: jdom-interest-bounces at jdom.org > > [mailto:jdom-interest-bounces at jdom.org] On Behalf Of Bashiro> > Sent: 22 January 2008 02:01> To: jdom-interest at jdom.org> > Subject: RE: [jdom-interest] Looping through attributes> > > > > Hello,> Thanks for the reply. I appreciate this;> > here is > the snip code;>   > > public  void searchDomain(Element > element, String dom) {>     >     List attributes = > element.getAttributes();>     >     if > (!attributes.isEmpty()) {>       Iterator iterator = > attributes.iterator();>       while (iterator.hasNext()) {>   >       Attribute attribute = (Attribute) > 
iterator.next();>         String name = attribute.getName();> >         String value = attribute.getValue();>   >             > if(name.equals("domain")&&value.equals(dom.trim())){>         >      jTextArea1.append(" Domain Exists: " + value + "\n"); >  >             return;>             }>     >         else {>     >        >           System.out.println("Domain does not exist  > " +(dom));      >            } >         }>        >     }> > >   }> > Thanks> Bashiro> Drammen-Norway> >  --- On Mon 01/21, > Michael Kay < mike at saxonica.com > wrote:> From: Michael Kay > [mailto: mike at saxonica.com]> To: bashiro at myway.com, > jdom-interest at jdom.org> Date: Mon, 21 Jan 2008 21:09:29 > -0000> Subject: RE: [jdom-interest] Looping through > attributes> > Show us your input, show us your code, and we > can help you > understand whereyou have gone wrong. JDOM > doesn't do anything > unless you ask it to.Michael > Kayhttp://www.saxonica.com/> > > Hello folks,> There is one > thing bodering 
me and I hope > someone could > help.> When I loop through attributes to search > for values. > How do I > stop jdom from not printing on any > attribute > that it loops through.> > Example:> I search for an > > attribute "domain" when the corresponding > value matches > > jdom returns found. But when not found; it > prints on all > > attributes and I get a list of not found, not > found, > > corresponding to the number of attributes in the documents.> > > > What code or how do i tell jdom to print "not found" only > > one time?> > Bashiro> Drammen-Norway> > > > > _______________________________________________> No banners. > > No pop-ups. No kidding.> Make My Way  your home on the Web > - > http://www.myway.com> > > > > _______________________________________________> To control > > your jdom-interest membership:> > > http://www.jdom.org/mailman/options/jdom-interest/youraddr@you> > > rhost.com> > > _______________________________________________> No banners. > No pop-ups. 
No kidding.> Make My Way  your home on the Web - > http://www.myway.com> > > > _______________________________________________> To control > your jdom-interest membership:> > http://www.jdom.org/mailman/options/jdom-interest/youraddr@you> > rhost.com> > _______________________________________________> No banners. No pop-ups. No kidding.> Make My Way  your home on the Web - http://www.myway.com> > > _______________________________________________> To control your jdom-interest membership:> http://www.jdom.org/mailman/options/jdom-interest/youraddr@you> rhost.com

_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way  your home on the Web - http://www.myway.com




More information about the jdom-interest mailing list