Click here to Skip to main content
15,890,982 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
Just need a small help,

Input (textBox1):

<rltocitm2>Section .01. In general 
<rltocitm2>Section .02 Letter ruling
<rltocitm2>Section .03 Closing agreement
<rltocitm2>Section .04 Determination letter
<rltocitm2>Section .05 Opinion letter

Output : With a button click

<rltocitm2>Section .01. In general</rltocitm2>
<rltocitm2>Section .02 Letter ruling</rltocitm2>
<rltocitm2>Section .03 Closing agreement</rltocitm2>
<rltocitm2>Section .04 Determination letter</rltocitm2>
<rltocitm2>Section .05 Opinion letter</rltocitm2>

Whichever tag(Highlighted) is starting at the beginning of the line should also appear at the end on the line.
Posted
Updated 4-Nov-12 23:37pm
v4
Comments
MT_ 5-Nov-12 6:06am    
were you able to solve the problem?

following code should help.

C#
string updatedLines;
string[] lines = textbox1.text.Split("\n");
foreach (string line in lines)
{
    Console.WriteLine(line);
    string updateLine = line + "</" +line.Substring(1,line.IndexOf('>'));
    Console.WriteLine(updateLine);
updatedLines += updateLine;
}


Now updatedLines variable will be your required string.
This considers your text is in a .text file and then reading it. You can replace it appropriately.

Hope that helps. If it does mark the answer as solution and/or upvote.

Thanks
Milind
 
Share this answer
 
v2
Comments
vamshivarma 5-Nov-12 4:58am    
Hi Milind,

Thankyou so much for the response, could you please change the code to window forms.

My Text is in textbox1 and it should run according to that with a button click.

Thanks in advance,

Vamsi
MT_ 5-Nov-12 5:00am    
I believe that much C# code you will be able to write, the important line is

string updateLine = line + "/> + line.Substring(1,line.IndexOf('>'));

This will update each line as you want.
Milind
MT_ 5-Nov-12 5:13am    
If you are accepting line by line you can simply replace line with TextBox1.Text. If you are accepting multi-line, you will have to split...Milind
vamshivarma 5-Nov-12 5:16am    
Milind, I am very new to this platform and trying to learn.
MT_ 5-Nov-12 5:19am    
Vamsi, agreed. But you will have to try, right? Are you accepting line by line. I mean user will enter one line (<rltocitm2>Section .01. In general) in the text-box and submit or whole bunch of lines?. As I said, if line by line simply use the line I said above, just replace line with TextBox1.Text.
string updateLine = line + "/> + textbox1.text.Substring(1,textbox1.text.IndexOf('>'));
Milind
Read the input into a string

C#
string input;
string output="";
string temp1="";
string temp2="";

temp1=input.subString(0,input.indexOf('>'));
temp2[0]=temp1[0];
temp2[0]='/';
for(int i=1;i<temp1.count;i++)>
     temp2[i+1]=temp1[i];

output=input+temp2;



I wrote code for one string u can do the same for all the input strings by taking the input into a string array and apply the same procedure for all the strings using a foreach or a for loop.
 
Share this answer
 
Comments
MT_ 5-Nov-12 5:44am    
How this is different than what is already proposed in my solution ?

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