Java Mailing List Archive

Home » JDOM Projects »

Re: [jdom-interest] Looping through attributes- success



Author LoginPost Reply

Hello again guys,

Thanks to all of you for the great ideas.
By using combination of the bits of ideas you all supplied
I have been able to achieve the goal
I combine the suggestions of both Mike and grzegorz;
here is the code snip I used:

List checkDomain = document.getRootElement().getChildren();
    for (int i = 0; i < checkDomain.size(); i++) {
       Element next = (Element)checkDomain.get(i);
        domainName= next.getAttribute("domain").getValue();

     if (domainName.equals(user_enteredValue)){
       System.out.println("Found domain")

 // when the last value is checked and nothing found    
      System.out.println("The domain does not exists");
Once again thanks to all of you! and to all jdom group!      

--- On Wed 01/23, Grzegorz Kaczor < grzegorz.kaczor@(protected):
From: Grzegorz Kaczor [mailto: grzegorz.kaczor@(protected)]
To: bashiro@(protected)
  Cc: jdom-interest@(protected)
Date: Wed, 23 Jan 2008 10:43:57 +0100
Subject: Re: [jdom-interest] Looping through attributes

No :).boolean found = falsefor (...) { if ("domain".equals(...)) {   ...   found = true;   break; }}So not found will be displayed once.But better use Michael's way, it is ok.String value = element.getAtttibute("domain");if (value == null || (!value.equals(dom.trim()))) display "not found"Regards,Grzegorz2008/1/22, Bashiro <bashiro@(protected):
[jdom-interest] Looping through attributes>> Hi>> 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 ?To have a boolean variable 'found' initialized to false before theloop, set it to true on find and use 'break' instead of 'return'? Justa suggestion.Grzegorz>> _______________________________________________> No banners. No pop-ups. No kidding.> Make My Way your home on the Web ->>> _______________________________________________> To control your jdom-interest membership:>

No banners. No pop-ups. No kidding.
Make My Way your home on the Web -

To control your jdom-interest membership:
©2008 - Jax Systems, LLC, U.S.A.