Format XML output from .NET Service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtdave
    New Member
    • Sep 2006
    • 1

    #1

    Format XML output from .NET Service

    I am new to creating .NET Services. I have created a service that does a database query and produces an XML file in OPML format. The service is being called call from a DHTML web page using XMLHttp. Everything is working great except for the service is html encoding my "<" and ">" characters to "&lt;" and "&gt;". For my XML output I need these characters to remain what they are. How do I tell the service not to perform the html encoding? I was wondering if this was in the Globalization setting in web.config? responseEncodin g is currently set to utf-8.

    I am using Visual Studio 2003 with .Net 1.1.

    OPML example

    Code:
    <opml version="1.0">
    <head>
    </head>
    <body>
      <outline text="fruit">
        <outline text="orange"/>
        <outline text="apple">
          <outline text="red delicious"/>
          <outline text="braeburn"/>
        </outline>
      </outline>
    </body>
    </opml>
    I need my XML output to look like the above example. All my "<" and ">" symbols are getting html encoded.

    Web service:

    Code:
    [WebMethod]
    public string EntityTable()
    {
    	try
    	{
    		StringBuilder xmlString = new StringBuilder();
    		//Add a bunch of XML text to string here
    		return xmlString.ToString();
    	}
    	catch (Exception ex)
    	{
    		return ex.ToString();
    	}
    }
    .NET is also adding this before and after the OPML:

    Code:
    <?xml version="1.0" encoding="utf-8" ?> 
      <string xmlns="http://localhost/webservices/">
      </string>
    I need the <?xml version="1.0" encoding="utf-8" ?> bit but I dont need the <string> tags. Is this a key to my problem?

    Any help appreciated. Thanks
Working...