This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how done this code  RSS feed

 
shinu pillai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first of all,i kindly request team please not kill me by giving the way of suggestion using xml parser.......can anybody please tell how this handle in reading follwing lines....
orderREF="1036578"><edm:OrderItem><edm:Order orderID="1036579"/> ineed to retoeve value 1036578 i use following code
final String START6_TAG="orderREF=";
final String END6_TAG=">";
final String END7_TAG="/>";
as per my observation,the follwing code need not work
if(line.indexOf(START6_TAG)> -1 ) {
//this code handle "orderREF=" in stands for order id
if(line.indexOf(END7_TAG,line.indexOf(START6_TAG))>-1){ //because if we use line.indexOf(END7_TAG)it take only first indexof that..
efound9=false;
}

asper above line this code cannot excecute.but igo to loop and set flag efound9=false, what is wrong in this code for handling
orderREF="1036578"/><edm:OrderItem><edm:Order orderID="1036579"/> this type of line that also comes in same program,here also we need output as 1036578.please tell me what i will do to hanndle these
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please not kill me by giving the way of suggestion using xml parser


You are, of course, writing an XML parser here. Not a general purpose one or a very robust one but a tiny special purpose parser. I'd probably take a step back and make a more general purpose parser that finds all tags and attributes. I'm not sure why you don't want to use one from a library but you could make your own to handle something as simple as your input pretty quickly. Any interest in that direction?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!