In html coding, these lines can be on separate lines without impacting the visual appearance. Are you feeding this into another system and need the <di><b>My line 1</b></di> all on the same line?
do you "need" to combine your lines as per your example, or do you simply "want" to combine the lines because you prefer the code to appear as your
output example? as
bbcompent1 said, HTML does not care.
regardless whether "need" or "want", did you want to code a program to do this?
or do you want to do it inside of Visual Studio?
for a programmed solution, you could use regex; for inside of Visual Studio, you could use a macro.
Please give your peers here at forums.asp.net more information so that we can perhaps help you find a solution.
g.
TIMTOWTDI =. there is more than one way to do it
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
you would next process the above transformed text as follows:
(a) save it to a file
(b) read the file from step (a) above, line by line ...
(c) if you get any line not ending in </di>, concatenate that line to a string
(d) if you get a line as "</di>", concatenate</di> to the string from step (c), above and output your reformated line.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
v-ambily
Member
155 Points
141 Posts
how to combine the string lines
Mar 01, 2012 10:43 AM|LINK
Hai..
Anyone please help me to combine the below string lines.i need to bring the middle text between <di> tag to the same row level of <di> tag
Input:
<di>
<b>English Controlled Assessments</b>
</di>
<di>
2 assessments
</di>
i want the output like the below format from the above lines
Output:
<di><b>English Controlled Assessments</b></di>
<di>2 assessments</di>
Thanks in advance
bbcompent1
All-Star
32994 Points
8509 Posts
Moderator
Re: how to combine the string lines
Mar 01, 2012 10:49 AM|LINK
In html coding, these lines can be on separate lines without impacting the visual appearance. Are you feeding this into another system and need the <di><b>My line 1</b></di> all on the same line?
gerrylowry
All-Star
20513 Points
5712 Posts
Re: how to combine the string lines
Mar 01, 2012 02:00 PM|LINK
@ v-ambily
do you "need" to combine your lines as per your example, or do you simply "want" to combine the lines because you prefer the code to appear as your output example? as bbcompent1 said, HTML does not care.
regardless whether "need" or "want", did you want to code a program to do this?
or do you want to do it inside of Visual Studio?
for a programmed solution, you could use regex; for inside of Visual Studio, you could use a macro.
Please give your peers here at forums.asp.net more information so that we can perhaps help you find a solution.
g.
TIMTOWTDI =. there is more than one way to do it
v-ambily
Member
155 Points
141 Posts
Re: how to combine the string lines
Mar 02, 2012 05:20 AM|LINK
Hai..
my requirement is,i have to make a conversion tool for converting html file to xml file.
From my input file ,i replaced the below tag
<td>
<p><font face="Arial" size="7"><b>English Controlled Assessments</b></font></p>
</td>
<td>
<p><font face="Arial" size="7">2 assessments</font></p>
</td>
after replacing i got this..
<di>
<b>English Controlled Assessments</b>
</di>
<di>
2 assessments
</di>
but i want to get the output in this format
<di><b>English Controlled Assessments</b></di>
<di>2 assessments</di>
Is there any way to do this in c# or any other way
Thanks in advance
gerrylowry
All-Star
20513 Points
5712 Posts
Re: how to combine the string lines
Mar 02, 2012 12:25 PM|LINK
@ v-ambily
is this a homework assignment?
Question: do you have XML Notepad 2007, free from Microsoft at http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7973?
Note: XML NotePad 2007 is an excellent tool for error checking XML code.
Did you know that XML is free format just like HTML?
To XML NotePad, your
is equivalent to your
generally if XML Notepad 2007 does not like some XML it gives an error ...
this was a surprise to me ....... i'm not sure why, possibly a bug?, but XML Notepad 2007 does not like your
without out giving me an error, if i paste this
into XML Notepad 2007, i only get this:
if i wrap the above code with <a> ... </a>, it works:
<?xml version="1.0" encoding="utf-8"?> <a> <di>2 assessments</di> <di> <b>English Controlled Assessments</b> </di> <di>2 assessments</di> <di> <b>English Controlled Assessments</b> </di> <di>2 assessments</di> <di> <b>English Controlled Assessments</b> </di> <di>2 assessments</di> <di> <b>English Controlled Assessments</b> </di> <di>2 assessments</di> </a>the point that i'm trying to make is that because like HTML, XML is a free format markup, this XML
is the same as this XML
While the above information, at least to me, is interesting, it does not answer your question.
ANSWERING YOUR QUESTION
you already know the answer ... using a technique similar to what you did to transform
into
you would next process the above transformed text as follows:
(a) save it to a file
(b) read the file from step (a) above, line by line ...
(c) if you get any line not ending in </di>, concatenate that line to a string
(d) if you get a line as "</di>", concatenate </di> to the string from step (c), above and output your reformated line.
g.
Sum8
Contributor
4141 Points
931 Posts
Re: how to combine the string lines
Mar 02, 2012 12:46 PM|LINK
Try this:
StringBuilder objSB = new StringBuilder(); objSB.AppendLine("<di>"); objSB.AppendLine("<b>English Controlled Assessments</b>"); objSB.AppendLine("</di>"); objSB.AppendLine("<di>"); objSB.AppendLine("2 assessments"); objSB.AppendLine("</di>"); string strNewString = objSB.ToString().Replace("<di>" + System.Environment.NewLine, "<di>").Replace(System.Environment.NewLine + "</di>", "</di>");Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"