Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert Vector to xml

 
peter brews
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Input will be vector whose each element will itself be a vector.Length of vector of each element may vary for different calls.Only the selected element needs to be placed in proper order in the output.For ex. field2 is not required in the output.Also field4 is placed before field3.Below is the code that I tried to write.Can any one help me with better solution.

The Input is vector :
"[ [field1,f1_val1,f1_val2,f1_val3,f1_val4] ,[field2,f2_val1,f2_val2,f2_val3,f2_val4],
,[field3,f3_val1,f3_val2,f3_val3,f3_val4,f3_val5],
,[field4,f4_val1,f4_val2]] )

Expected output is :
< FIELD Row=1>
<field1>f1_val</field1>
<field4>f2_val1</filed4>
<field3>f3_val1</field3>
</FIELD>
< FIELD Row=2>
<field1>f1_va2</field1>
<field4>f2_val2</filed4>
<field3>f3_val2</field3>
</FIELD>
< FIELD Row=3>
<field1>f1_va3</field1>
<field3>f3_val3</field3>
</FIELD>
< FIELD Row=4>
<field1>f1_val4</field1>
<field3>f3_val4</field3>
</FIELD>
< FIELD Row=5>
<field3>f3_val5</field3>
</FIELD>
Code:

edited by Dave to put the code in the UBB code tags.
[ February 27, 2002: Message edited by: Dave Vick ]
[ February 27, 2002: Message edited by: smita agarnal ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic