Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
vXMLStream = YYYYMM="200502" ename="RAJ" age="23" sex="Male" category="Poor" edu_qualification="BBA" community="SC" religion="HINDU" occupation="farmer" month_income="2000"

Here i splited this and to stored in an array variable. for that i tried the following. Because here i want to replace occupation="farmer" this one array position alone alone.
and finally i want to concatenate all the array indexes and stored in the vXMLStream variable.

VB
Dim sourceString As String = vXMLStream
Dim arrayOfStrings() As String = sourceString.Split(" ")
System.Web.HttpContext.Current.Response.Write("<script language='javascript'>alert('The following errors have occurred:\n" + arrayOfStrings(2) + "' );</script>")


But Now once i print the data i am getting output like this:-

YYYYMM="200502"
ename="RAJ"
age="23"
sex="Male"
category="Poor"
edu_qualification="BBA"
community="SC"
religion="HINDU"
occupation="farmer"

Here i want to replace this (occupation="farmer" this is static one) finally i want to concatenate all the array indexes and stored in the vXMLStream variable.
please post solution for this post
Posted
Updated 23-Feb-12 18:54pm
v5
Comments
Varun Sareen 24-Feb-12 0:14am    
edit for: formatting done
CRDave1988 24-Feb-12 0:33am    
Please Don't Re-post Question. Improve ur question if u need more help:
http://www.codeproject.com/Answers/334067/How-to-split-this-I-want-to-take-the-value-alone-i
rajrprk 27-Feb-12 6:03am    
Hello this is another post but relevant to that post

1 solution

You can do it one of two ways: use Replace instead on Split:
VB
Dim output as String = sourceString.Replace("occupation=""farmer""", "")

Or remove the string from the list in a loop
VB
For i As Integer = 0 To arrayOfStrings.Length - 1
    If arrayOfStrings(i) = "occupation=""farmer""" Then
        arrayOfStrings(i) = ""
    End If
Next

To concatenate is simple:
VB
vXMLStream = String.Join(" ", arrayOfStrings)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900