Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with using java "Do While"

Status
Not open for further replies.

prevent

Programmer
Jan 29, 2006
1
US
Need a little help..Thank you...Thank you... Thank you

I completed my first java programming class six months ago. Now I been assign a project using java. So far it's comming along pretty good. I'm trying to use the "Do While" to accomplish the following in JDeveloper.

Example of the xml file:

<looptag>
looptag
<fielda>
some data
<fieldb>
some data
<fieldc>
some data
<fieldb>
some data
<fieldc>
some data
<fielda>
some data
<fieldc>
some data
<fieldc>
some data
<fielda>
some data
<fieldb>
some data
<fieldc>
some data
<fieldc>
some data
<endloop>
endloop

There are repetitive tags for field a, b, and c. Not necessary the same count for each field. I would like to write out the fields in the same order looping through the file order.



Is this the right concept.?

String looptag = "looptag";
String t = "";
String s = "";

If looptag.indexOf ("looptag") // starting point for the loop
Do
{
if fielda > 0 write to s.
else
if fieldb > 0 write to s.
else
if fieldc > 0 wite to s
}
While fielde.indexOf not equal "endloop" // end of the loop


 
That *text* is not valid or even well-formed XML.
If it were, or is meant to be, I would use an XML parser, which would be a lot easier.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top