0

In an xml file I stored code snippet but while retrieve that code from an xml file it is displaying in a single line what should i have to do in order to get output as same original

<paper>
<question>"public class MyClass 
          { 
            public int x;
            public int y; 
            public void   Method()
            {
              x=10;
            } 
          }"
</question>
</paper> 

in form.cs

XDocument doc=new XDocument();
doc.load(path of an xml file);
var questions=doc.descedants("question");
foreach( var ques in questions)
{
label.Text=ques.Value;
}
this.Controls.Add(label1);

my output is

public class MyClass      { public int x;   public int y;   public void Method()   {    x=10;   }    }
  • 1
    Is this a homework assignment? http://stackoverflow.com/questions/33314820/is-it-possible-display-the-text-in-code-snippet-format-dynamically-using-c-sharp – Loathing Oct 26 '15 at 05:37
  • No sir .... i'm the beginner to this c# and xml sir so please help me how to get back from this problem sir... – Yamuna Pattem Oct 26 '15 at 05:45

1 Answers1

1

Your code should be wrapped in a CDATA block. Code has way to many characters that overlap with XML markup and your line break problem will be fixed, too.

Community
  • 1
  • 1
nvoigt
  • 61,531
  • 23
  • 73
  • 116