Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 31st, 2007, 08:05 AM
GS GS is offline
Authorized User
 
Join Date: Sep 2003
Location: , , .
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>EASMITH@.com</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:00EricSmithMrEASMITH@.comSHBY003F1817000TEFLSPC 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
  #2 (permalink)  
Old August 31st, 2007, 12:45 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 08:19 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM



All times are GMT -4. The time now is 08:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.