This is a migrated thread and some comments may be shown as answers.

How to show XML document content?

6 Answers 288 Views
HTMLPlaceHolder
This is a migrated thread and some comments may be shown as answers.
andrew rekvils
Top achievements
Rank 1
andrew rekvils asked on 27 Jan 2010, 08:53 PM
How to show XML document content in HTMLPlaceholder control? I have XML document content in my silverlight app's string variable. I want to feed it in to the HTMLPlaceholder control and see Browser showing XML document parsed just like browsers typically show XML documents parsed and colored.

Thank you,
Andrew

6 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 28 Jan 2010, 02:20 PM
Hello andrew rekvils,

Html placeholder will show the XML file the way the browser is displaying it. It do not have any functionality to deal with XML, other than that. Just point the SourceUrl property to the XML file.

Sincerely yours,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrew rekvils
Top achievements
Rank 1
answered on 28 Jan 2010, 04:22 PM
My XML Document is not an external file or server resource that can be reached through Source Url property. My XML document is a string in my Silverlight application memory. I don't think SourceUrl property will help in this case. What can help then, if anything?

Thank you,
Andrew
0
Valentin.Stoychev
Telerik team
answered on 29 Jan 2010, 12:15 PM
Hi andrew rekvils,

You can parse the XML and convert it to HTML and then to pass it to the HtmlPlaceholder. See here how to display html string with the HtmlPlaceholder in Silverlight:
http://www.telerik.com/help/silverlight/radhtmlplaceholder-howto-displayhtml.html

Kind regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
andrew rekvils
Top achievements
Rank 1
answered on 29 Jan 2010, 02:15 PM

Unfortunately it will not be the same as if I had SourceUrl initialized with the path to valid XML file. In the later case HtmlPlaceholder uses underlying browser  to display XML content and that automatically creates colors indents, etc.. Also XML document in this case is "interactive" because its XML elements and nodes can be collapsed/expanded (this what IE and some other browsers do with external XML documents by default). By using my own custom formatting of XML string as HTML document I will not get this "interactivity".

Why wouldn't  you had HTMLPlaceholder property like Content-Type that by default is text/html and if it is text/xml it will interpret HtmlSource value as XML but not HTML and act on it accordingly. At the end of the day all we need is to let underlying browser to act on XML document the way it already can, we just need this functionality to be exposed through HTMLPlaceholder control.

Thanks,
Andrew

0
Valentin.Stoychev
Telerik team
answered on 29 Jan 2010, 02:43 PM
Hi andrew rekvils,

Basically we are using an iframe for external content and we dont have the option to change the content type.

Another option for you which will not require the parsing would be to save the XML content by using a service on the server, and then to direct the HtmlPlaceholder to the saved url ( e.g. to the XML file). This is not very good from performance point of view, but it all depends from your application requirements.

Sincerely yours,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
robert hutchison
Top achievements
Rank 1
answered on 25 Feb 2010, 10:10 PM
Hi,

Here is what we are doing. Now, what we have as our input is XML that is in one large string (everything is in one line and there were spaces in the original XML file at the beginning of each line)...  Here's the VB code:

Dim MessageDetails As New RadHtmlPlaceholder 
Dim TmpString As String 
 
AuditGridRow = TryCast(Me.AuditsGrid.SelectedItem, tblMessageAudit) 
radPane2.Header = Left(e.NewCell.Content.ToString, 8) & "..." 
TmpString = AuditGridRow.XMLMessage.ToString 
TmpString = TmpString.Replace("<""&lt;"
TmpString = TmpString.Replace("> ""~~~~")  ' handle this afterwards 
TmpString = TmpString.Replace(">""&gt;")  ' the > that don't have a space after them 
TmpString = TmpString.Replace("~~~~""&gt;<br/>"' so they have newlines in the HTML 
TmpString = TmpString.Replace("  ""&nbsp&nbsp"
TmpString = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='Content-Type' /><title>XML Message</title></head><body><div style='font-family: 'Courier New', Courier, monospace;   font-size: x-small; width:100%;' >" & TmpString 
TmpString = TmpString & "</div></body></html>" 
 
MessageDetails.HtmlSource = TmpString 

well, the AuditsGridRow and radPane2 rows are where I pull the data out from a grid and manage a docking panel...

  1. it gets the job done and the output looks OK, except for the font
  2. everyone who sees the code knows immediately what it is doing
  3. it is fast
  4. it will never win me any award for 'sophisticated programmer of the year'  :-) but I didn't see anyone step up with anything better either :-)

Now, I need to try and figure out why it always shows up in 12 point Times Roman, no matter what I do.

Rob
Tags
HTMLPlaceHolder
Asked by
andrew rekvils
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
andrew rekvils
Top achievements
Rank 1
robert hutchison
Top achievements
Rank 1
Share this question
or