File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Same old pproblem.. a bit urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Same old pproblem.. a bit urgent " Watch "Same old pproblem.. a bit urgent " New topic
Author

Same old pproblem.. a bit urgent

vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
hello
i have problem , my String(not xml) just a java string is like this String response = "<XArC version="2.0" service="GetHitList" type="response"><folder name='Vermoegensstatus'><document><docid>100000</docid><metainfo> " i want to search this string and get all the values which are between <docid> and </docid > , and if the value is not there then the method should return peacefully
i have started this method pls complete this ..
public String getPat(String response , String "start" , String "end" ) {
.............
.........
......
}
just for sake i have done this pls complete this method.


SCJP, SCWD <br />A farmer learns more from a bad harvest than a good one.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Vivek,
Not a very good start ...

How about this for the ending?
Regards,
Manfred.
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
hi Manfred ,
Thanks a lot for ur generosity. i will post my experience with ur snippet as soon as it works.
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
"<XArC version="2.0" service="GetHitList" type="response"><folder name='Vermoegensstatus'><document><docid>100000</docid><metainfo><docid>5678789457895</docid><docid>5678954</docid> "
hi manfred ur method works perfectly fine but the problem is that sometimes i get number of (more than one) occurence of the pattern <docid></docid> , ur method returns only one value but if more than one value is present its not returning( i mean if there are two tags <docid></docid> with values then it should return the 2 values but only one is returned how can i deal this problem ..how can i intoduce a looping for this stuff, to look for multiple occurences of docids ..pls advice on this
[ April 25, 2002: Message edited by: vivek sivakumar ]
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Vivek,
Sure make it hard. To get variable number of return values I would make use of the collection interface. The following program shows how the method would be altered and how to use it and the results it produces.

Enjoy,
Manfred.
vivek sivakumar
Ranch Hand

Joined: Aug 09, 2001
Posts: 187
well its returning me a collection but if i want it in terms like separater string values like 10001, 10002,..... then how can i do it .
[ April 30, 2002: Message edited by: vivek sivakumar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Same old pproblem.. a bit urgent