Skip to main content
added 77 characters in body
Source Link
alex
  • 121
  • 1
  • 6

I have been struggling to format myThere is an issue with the output using AwkXML format due to Record separator (RS = "\n \n"). If anybody could point my mistake or provide solution, itThe group of data is separated by an empty line. Any suggestion would be very much helpful to obtain the desired output.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS"\\n";RS = "\n\n";"\\n\\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$2"</marks>" }
{ print "<subject>"$3"</subject>" }
{ print "</candidate>" }
{print " " }' input.txt > candiatefinaloutput.xml

With the above code, getting an output as below:

<candidate>
<name>alex<\name>
<marks><\marks>
<subject><\subject>

<name>Marks300<\name>
<marks><\marks>
<subject><\subject>

<name>SubjectScience<\name>
<marks><\marks>
<subject><\subject>

<name>Robin<\name>
<marks><\marks>
<subject><\subject>

and so on.

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$2"</marks>" }
{ print "<subject>"$3"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

With the above code, getting an output as below:

<candidate>
<name>alex<\name>
<marks><\marks>
<subject><\subject>

<name>Marks300<\name>
<marks><\marks>
<subject><\subject>

<name>SubjectScience<\name>
<marks><\marks>
<subject><\subject>

<name>Robin<\name>
<marks><\marks>
<subject><\subject>

and so on.

There is an issue with the output XML format due to Record separator (RS = "\n \n"). The group of data is separated by an empty line. Any suggestion would be very much helpful to obtain the desired output.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\\n";RS = "\\n\\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$2"</marks>" }
{ print "<subject>"$3"</subject>" }
{ print "</candidate>" }
{print " " }' input.txt > candiatefinaloutput.xml

With the above code, getting an output as below:

<candidate>
<name>alex<\name>
<marks><\marks>
<subject><\subject>

<name>Marks300<\name>
<marks><\marks>
<subject><\subject>

<name>SubjectScience<\name>
<marks><\marks>
<subject><\subject>

<name>Robin<\name>
<marks><\marks>
<subject><\subject>

and so on.

added 24 characters in body
Source Link
alex
  • 121
  • 1
  • 6

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$1"<"<marks>"$2"</marks>" }
{ print "<subject>"$1"<"<subject>"$3"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

With the above code, getting an output as below:

<candidate>
<name>alex<\name>
<marks><\marks>
<subject><\subject>

<name>Marks300<\name>
<marks><\marks>
<subject><\subject>

<name>SubjectScience<\name>
<marks><\marks>
<subject><\subject>

<name>Robin<\name>
<marks><\marks>
<subject><\subject>

and so on.

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$1"</marks>" }
{ print "<subject>"$1"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$2"</marks>" }
{ print "<subject>"$3"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

With the above code, getting an output as below:

<candidate>
<name>alex<\name>
<marks><\marks>
<subject><\subject>

<name>Marks300<\name>
<marks><\marks>
<subject><\subject>

<name>SubjectScience<\name>
<marks><\marks>
<subject><\subject>

<name>Robin<\name>
<marks><\marks>
<subject><\subject>

and so on.

added 24 characters in body
Source Link
alex
  • 121
  • 1
  • 6

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

AlexAlex
Marks300Marks300
SubjectScienceSubjectScience

RobinRobin
Marks200Marks200
SubjectChemistrySubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$1"</marks>" }
{ print "<subject>"$1"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex Marks300 SubjectScience

Robin Marks200 SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$1"</marks>" }
{ print "<subject>"$1"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml

I have been struggling to format my output using Awk. If anybody could point my mistake or provide solution, it would be very helpful.

Following is my input which is present in input.txt

Alex
Marks300
SubjectScience

Robin
Marks200
SubjectChemistry

I am trying to get an output as below:

<candidate>
<name>Alex</name>
<marks>Marks300</marks>
<subject>SubjectScience</subject>
</candidate>

<candidate>
<name>Robin</name>
<marks>Marks200</marks>
<subject>SubjectChemistry</subject>
</candidate>

I am trying to use the following code but it is not working:

awk 'BEGIN{FS = "\n";RS = "\n\n";
print " "}
{ print "<candidate>" }
{ print "<name>"$1"</name>" }
{ print "<marks>"$1"</marks>" }
{ print "<subject>"$1"</subject>" }
{ print "</candidate>" }
{print " " } input.txt > candiatefinaloutput.xml
retag and enclose code
Source Link
PersianGulf
  • 11.3k
  • 11
  • 56
  • 83
Loading
Source Link
alex
  • 121
  • 1
  • 6
Loading