14

I've been searching for a way to show formatted xml in a textbox, everything I've found so far points towards reading in xml from a file and formatting that, however I want to show xml which is held in a database field.

The idea is that a user will have records returned to a gridview, the gridview will show everything apart from the xml message due to its size. They can then select the record and show the xml on a pop-up form.

I have the xml passed to the pop-up form, just not sure how to handle it. Any ideas welcome.

5
  • 3
    Is this on a web site or a windows application?
    – Sean Airey
    Jun 3, 2013 at 10:32
  • tell me what step you are right now... are you able to GET the XML from the DB? if yes, then i would assume that you already have the string ready to be written in that UI Control that you have? in this case, a pop-up?
    – aiapatag
    Jun 3, 2013 at 10:32
  • correct, have the xml and just looking for the best way to write it to the pop-up
    – DarkW1nter
    Jun 3, 2013 at 10:43
  • sorry, its a web site
    – DarkW1nter
    Jun 3, 2013 at 10:54
  • 1
    You should take a look at alexgorbatchev.com/SyntaxHighlighter, which allows you to display code with syntax hightligting. Simply wraps the encoded xml string into a <pre class="brush: xml"> tag, and let the plugin do its jobs
    – Steve B
    Jun 3, 2013 at 10:55

1 Answer 1

37

Got round it by using

xmlOut = System.Xml.Linq.XDocument.Parse(txtXml).ToString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.