Ankit  Shukla

Ankit Shukla

  • NA
  • 681
  • 116.4k

add a node inside a particular node in xml

Nov 7 2015 5:31 AM
Hello;
 
    I have a xml file like this:
 
<QUIZ>
<SECTIONDETAILS>
<SECTION ISOPTIONAL="N">
<SECNAME>General Awareness</SECNAME>
<QUESTION TYPE="MCQ">
<NAME><![CDATA[FUll Form OF SBI]]></NAME> 
<ANSWER CORRECT="FALSE" VALUE="1"><![CDATA[Sikkim Bank Of India]]></ANSWER>
<ANSWER CORRECT="TRUE" VALUE="2"><![CDATA[State Bank Of India]]></ANSWER>
</QUESTION>
</SECTION>
</SECTIONDETAILS>
</QUIZ>
 
I need to add some more questions in xml file using c# code. So that output should like this-
 
<QUIZ>
<SECTIONDETAILS>
<SECTION ISOPTIONAL="N">
<SECNAME>General Awareness</SECNAME>
<QUESTION TYPE="MCQ">
<NAME><![CDATA[FUll Form OF SBI]]></NAME>
<ANSWER CORRECT="FALSE" VALUE="1"><![CDATA[Sikkim Bank Of India]]></ANSWER>
<ANSWER CORRECT="TRUE" VALUE="2"><![CDATA[State Bank Of India]]></ANSWER>
</QUESTION>
<QUESTION TYPE="MCQ">
<NAME><![CDATA[FUll Form OF SBI]]></NAME>
<ANSWER CORRECT="FALSE" VALUE="1"><![CDATA[Sikkim Bank Of India]]></ANSWER>
<ANSWER CORRECT="TRUE" VALUE="2"><![CDATA[State Bank Of India]]></ANSWER>
</QUESTION> 
</SECTION>
</SECTIONDETAILS>
</QUIZ>
 
But My Output is like this-
 

<QUIZ>
<SECTIONDETAILS>
<SECTION ISOPTIONAL="N">
<SECNAME>General Awareness</SECNAME>
<QUESTION TYPE="MCQ">
<NAME><![CDATA[FUll Form OF SBI]]></NAME>
<ANSWER CORRECT="FALSE" VALUE="1"><![CDATA[Sikkim Bank Of India]]></ANSWER>
<ANSWER CORRECT="TRUE" VALUE="2"><![CDATA[State Bank Of India]]></ANSWER>
</QUESTION>
</SECTION>
</SECTIONDETAILS>
<SECTIONDETAILS>
<SECTION ISOPTIONAL="N">
<SECNAME>General Awareness</SECNAME>
<QUESTION TYPE="MCQ">
<NAME><![CDATA[FUll Form OF SBI]]></NAME>
<ANSWER CORRECT="FALSE" VALUE="1"><![CDATA[Sikkim Bank Of India]]></ANSWER>
<ANSWER CORRECT="TRUE" VALUE="2"><![CDATA[State Bank Of India]]></ANSWER>
</QUESTION>
</SECTION>
</SECTIONDETAILS>
</QUIZ>
 
Please help its really urgent.. Thanks 
 
 
 
 
 

Answers (2)