0

I am new C#,

I was wondering what the best way would be to display xml string on a asp.net webpage, I tried putting onto a textbox.. but it is not formatted.. is there any way I can make it look formatted. I am getting this XML as a response to a web service so dont know what the structure of xml would be like to read node by node as my xml has come custom elements. this xml is used by users in their projects so formatting is important.. can someone help me with this.. the sample xml file might be like this

<geonames>
    <totalResultsCount>1</totalResultsCount>
         <code><postalcode>90210</postalcode>
       <name>Beverly Hills</name>
         <countryCode>US</countryCode>
       <lat>34.09011</lat>
         <lng>-118.40648</lng>
         <adminCode1>CA</adminCode1>
          <adminName1>California</adminName1>
         <adminCode2>037</adminCode2>
         <adminName2>Los Angeles</adminName2>
          <adminCode3/>testing123<adminName3/>
           </code>
            </geonames>

thanks in advance, PS: Let me know if i have make the question more specific or make it more clear.

1
  • check this Answer Commented May 14, 2012 at 17:02

2 Answers 2

1

Have you tried using the xml control:

 <asp:xml ID="Xml1" runat="server"></asp:xml>

You can find an example of using it here.

The defaultss.xsl for IE is pre-XSLT 1.0. You can find valid versions of the file here and here.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use a simple literal control with XML encoding to achieve this. The following post on stackoverflow discusses it in detail. This however just formats the data in terms of line feeds and indentation, it does not color the nodes

Display XML on an ASP.NET page

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.