2
Answers

add a node inside a particular node in xml

Ankit  Shukla

Ankit Shukla

9y
385
1
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)