<p><h1><b>The skills tested</b></p>
<p><li></p>
<p>There will be at least one question based on each text in the first four questions.</p>
<p>The five questions you will be asked will test your ability to:</p>
<p><li></p>
<p>find information (this is <b>information retrieval) </b> (4 marks)</p>
<p>write about what is being <b>suggested</b> or <b>inferred </b> (4 marks)</p>
<p><b>find evidence</b> and say <b>what it is suggesting </b> (8 marks)</p>
<p>write about <b>language </b> (12 marks)</p>
<p>compare the <b>presentational features</b> used in texts (12 marks)</p>
<p></li></p>
<p>All four of the Assessment Objectives are tested through this part of the exam.</p>
<p></li></p>
<p><h2>What to expect from the texts</p>
I have text file like this format..i need to convert the file format to the below tag format
I took each line using readline from the text file.I replaced <p><li></p> to <list>
and <p></li></p> to </list>.
but i am facing problem inside <list> tag.How can convert the inside tag. i want to change the
<p> tag inside of the <list> tag..
Anyone please help me ,how to do this nd what is the way or logic behind of this to do
Thanks in advance....
string oldText = "<p>There will be at least one question based on each text in the first four questions.</p>";
string newText = oldText.Replace("<p>", "<item>").Replace("</p>", "</item>");
Sumit Pathak ------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
Marked as answer by v-ambily on Feb 10, 2012 10:19 AM
sr = new StreamReader(openFileDialog1.FileName);
while ((line = sr.ReadLine()) != null)
from this i get each line at each time to line variable...i want to change the <p> tag only inside the <list> tag..if i i use the above coding that will affect all the <p> tag in the text file..Anyone pleasse tell me that how can i focus in between list
opening and list closing
i've answered it with a pseudo code example that you can translate into c# by taking advantage of the many c# functions ... you'll learn more by trying to at least partially solve your problems yourself ... then you can show us code snippets when you get
into difficulties and we can point you in the right direction.
please note: it's not really a good idea to post the same question in multiple threads; while i can not speak on behalf of the moderators, i suspect it's not a practice they'd appreciate.
just my opinion.
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
v-ambily
Member
155 Points
141 Posts
convert the text format to another format
Feb 10, 2012 08:14 AM|LINK
Hai...
<p><h1><b>The skills tested</b></p>
<p><li></p>
<p>There will be at least one question based on each text in the first four questions.</p>
<p>The five questions you will be asked will test your ability to:</p>
<p><li></p>
<p>find information (this is <b>information retrieval) </b> (4 marks)</p>
<p>write about what is being <b>suggested</b> or <b>inferred </b> (4 marks)</p>
<p><b>find evidence</b> and say <b>what it is suggesting </b> (8 marks)</p>
<p>write about <b>language </b> (12 marks)</p>
<p>compare the <b>presentational features</b> used in texts (12 marks)</p>
<p></li></p>
<p>All four of the Assessment Objectives are tested through this part of the exam.</p>
<p></li></p>
<p><h2>What to expect from the texts</p>
I have text file like this format..i need to convert the file format to the below tag format
<p><li></p> <list>
<p>[any-text]</p> <litem> [any-text]</ litem>
<p>[any-text]</p> <litem> [any-text]</ litem>
<p><li></p> to <list>
<p>[any-text]</p> ----> <litem> [any-text]</ litem>
<p>[any-text]</p> <litem> [any-text]</ litem>
<p></li></p> </list>
<p>[any-text]</p> <litem> [any-text]</ litem>
<p>[any-text]</p> <litem> [any-text]</ litem>
<p></li></p> </list>
I took each line using readline from the text file.I replaced <p><li></p> to <list>
and <p></li></p> to </list>.
but i am facing problem inside <list> tag.How can convert the inside tag. i want to change the
<p> tag inside of the <list> tag..
Anyone please help me ,how to do this nd what is the way or logic behind of this to do
Thanks in advance....
Dr. Acula
Participant
1447 Points
322 Posts
Re: convert the text format to another format
Feb 10, 2012 08:46 AM|LINK
use Regex to match the strings you want to replace
Sum8
Contributor
4141 Points
931 Posts
Re: convert the text format to another format
Feb 10, 2012 09:03 AM|LINK
Try this sample code:
string oldText = "<p>There will be at least one question based on each text in the first four questions.</p>"; string newText = oldText.Replace("<p>", "<item>").Replace("</p>", "</item>");Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
v-ambily
Member
155 Points
141 Posts
Re: convert the text format to another format
Feb 10, 2012 09:38 AM|LINK
Hai friend,
i am reading the text file using streamreader
sr = new StreamReader(openFileDialog1.FileName);
while ((line = sr.ReadLine()) != null)
from this i get each line at each time to line variable...i want to change the <p> tag only inside the <list> tag..if i i use the above coding that will affect all the <p> tag in the text file..Anyone pleasse tell me that how can i focus in between list opening and list closing
Thanks in advance...
Sum8
Contributor
4141 Points
931 Posts
Re: convert the text format to another format
Feb 10, 2012 09:45 AM|LINK
Declare a boolean variable say 'boolIsListOpen' with default value as 'False'.
Now, while reading each line, when the string '<list>' will occur, set boolIsListOpen = True
And, when '</list> will occur, set boolIsListOpen = False
For replacing, use the code in my previous post. But, based on the value in the boolIsListOpen.
If it's True then only replace the values in the string.
Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
v-ambily
Member
155 Points
141 Posts
Re: convert the text format to another format
Feb 10, 2012 10:19 AM|LINK
Thank you Sumit
v-ambily
Member
155 Points
141 Posts
Re: convert the text format to another format
Feb 13, 2012 04:24 AM|LINK
Hai friend,
can you help me to do this also please..
<p><toc></p> <contents>
<p>[space][any-text]$$[any-text]</p> to <entry2><secname>[any-text]</secname> <pageno>[anytext]</pageno></entry2>
<p>[any-text]$$[any-text]</p> ---> <entry1><secname>[any-text]</secname> <pageno>[anytext]</pageno></entry1>
<p>[space][any-text]</p> <entry2><secname>[any-text]</secname> </entry2>
<p>[any-text]</p> <entry1><secname>[any-text]</secname> </entry1>
<p></toc></p> </contents>
My text file is
<p><toc></p>
<p><hd>Revision Guide Contents</p>
<p>Understanding and producing</p>
<p> non-fiction texts: about your exam$$4</b></font></p>
<p>Understanding non-fiction texts$$6</p>
<p>Kinds of non-fiction texts$$8</p>
<p></toc></p>
Thanks in advance
Sum8
Contributor
4141 Points
931 Posts
Re: convert the text format to another format
Feb 13, 2012 05:46 AM|LINK
Try this:
string[] stringInput = { "<p><toc></p>", "<p> [any-text]$$[any-text]</p>", "<p>[any-text]$$[any-text]</p>", "<p> [any-text]</p>", "<p>[any-text]</p>", "<p></toc></p>" }; int intCount = 3; for (int i = 0; i < stringInput.Length; i++) { intCount = intCount == 0 ? 2 : intCount; stringInput[i] = stringInput[i].Trim().Replace("<p><toc></p>", "<contents>").Replace("<p></toc></p>", "</contents>").Replace("<p>", "<entry" + intCount + "><secname>").Replace("$$", "</secname> <pageno>").Replace("</p>", "</pageno></entry" + intCount + ">").Replace("<secname> ", "<secname>"); intCount--; }Sumit Pathak
------------------
ThisPost = Helped == True ? "Mark As Answer" : "Elaborate your problem in more details"
gerrylowry
All-Star
20577 Points
5721 Posts
Re: convert the text format to another format
Feb 13, 2012 06:15 AM|LINK
@ v-ambily
you've already posted your second question here http://forums.asp.net/t/1768431.aspx/1?convert+the+text+file.
i've answered it with a pseudo code example that you can translate into c# by taking advantage of the many c# functions ... you'll learn more by trying to at least partially solve your problems yourself ... then you can show us code snippets when you get into difficulties and we can point you in the right direction.
please note: it's not really a good idea to post the same question in multiple threads; while i can not speak on behalf of the moderators, i suspect it's not a practice they'd appreciate.
just my opinion.
g.
TIMTOWTDI =. there is more than one way to do it
v-ambily
Member
155 Points
141 Posts
Re: convert the text format to another format
Feb 13, 2012 07:15 AM|LINK
Hai
for replacing i used the same way as in the first question.so i put the next question in the same post.
Thanks