• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

convert Vector to xml

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic