Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2007, 08:05 AM
GS GS is offline
Authorized User
 
Join Date: Sep 2003
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default xml displayed in textbox

I have a field in a SQL Server database which holds XML (data type set to ntext).

When trying to display this in a label for example on an ASP.net field instead of getting the field in format:

<ns0:Resource xmlns:ns0=\"http://.EPM.TransferResources.BizTalk.Schemas.ResourcesGE N\"><ns0:EMPLID>816048L</ns0:EMPLID><ns0:START_DATE>2002-07-02T00:00:00.000000-00:00</ns0:START_DATE><ns0:FORENAME>Eric</ns0:FORENAME><ns0:SURNAME>Smith</ns0:SURNAME><ns0:INITIALS></ns0:INITIALS><ns0:TITLE>Mr</ns0:TITLE><ns0:EMAIL>[email protected]</ns0:EMAIL><ns0:PRIMARY_LOCATION>SHB</ns0:PRIMARY_LOCATION><ns0:_STAFF>Y</ns0:_STAFF><ns0:ORG_LEVEL>003</ns0:ORG_LEVEL><ns0:DEPTID>F1817000</ns0:DEPTID><ns0:COST_CENTRE>TEFLSPCS</ns0:COST_CENTRE><ns0:DIVISION>DTTESBSS</ns0:DIVISION><ns0:RBS>NDERA.DTXXXDIV.DTTESBSS.DTTE LBDS.TEFLSPCS.F1817.F1817000</ns0:RBS><ns0:RATE_A>0</ns0:RATE_A><ns0:RATE_B>0</ns0:RATE_B><ns0:RATE_C>13.09</ns0:RATE_C><ns0:Meta_GUID>816048L</ns0:Meta_GUID></ns0:Resource>

I get the values returned as a string:

816048L2002-07-02T00:00:00.000000-00:[email protected] SDTTESBSSNDERA.DTXXXDIV.DTTESBSS.DTTELBDS.TEFLSPCS .F1817.F18170000013.09816048L

How would I go about breaking up the string to get the values?

All I have is:

       string MessageBody = "";

        MessageBody = ds.Tables["ErrMessage"].Rows[0][14].ToString();

       //TODO: Need to workout how to display the xml well

        Label2.Text = MessageBody.ToString();

If I try to display in a textbox the format is correct (i.e. with the tags <>) but, it is one one long line.

Hope this makes sense

TIA

G
 
Old August 31st, 2007, 12:45 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You can't use a label to display XML like that, it just thinks it's HTML tags that it doesn't understand and ignores them. You can either use a textarea or textbox set to multiline or use something like Server.HtmlEncode to escape the output.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
xml declaration not displayed zsheema XSLT 10 May 15th, 2008 04:36 AM
pointing cursor from one textbox to other textbox lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2007 03:41 PM
Write XML element into textbox with XSLT tcstom XSLT 4 July 5th, 2006 04:08 AM
XML to be displayed in a pop-up crmpicco Classic ASP Basics 1 February 10th, 2005 09:19 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.