473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

xml document

I have a string which contains an xml document in my app.

Does anyone know of an easy way to display XML data in a browser, with
nice
indentations between nodes, and maybe even the +/- controls that IE
uses
when displaying XML?

Matt

Nov 17 '05 #1
3 1485

<st****@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
I have a string which contains an xml document in my app.

Does anyone know of an easy way to display XML data in a browser, with
nice
indentations between nodes, and maybe even the +/- controls that IE
uses
when displaying XML?


IE uses a stylesheet that generates the html for a given XML document, if
memory serves, which may not be what you want. Have you tried simply using
the IE browser and having it host it?
Nov 17 '05 #2
You need an xsl file to render HTML from XML. Internet Explorer provides one
built-in, but it you want another your XML file has to include a reference
to it:

<?xml version="1.0" encoding="Windows-1252" ?>
<?xml-stylesheet type="text/xsl" href="file:///C:\myXsl.xsl" ?>
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

<st****@gmail.com> escribió en el mensaje
news:11*********************@g44g2000cwa.googlegro ups.com...
I have a string which contains an xml document in my app.

Does anyone know of an easy way to display XML data in a browser, with
nice
indentations between nodes, and maybe even the +/- controls that IE
uses
when displaying XML?

Matt

Nov 17 '05 #3
In article <11*********************@g44g2000cwa.googlegroups. com>,
<st****@gmail.com> wrote:

: I have a string which contains an xml document in my app.
:
: Does anyone know of an easy way to display XML data in a browser, with
: nice indentations between nodes, and maybe even the +/- controls that
: IE uses when displaying XML?

Let IE do the work for you. Below is a simplified version of the code
at http://xrl.us/gq7i ("Hosting an ActiveX Control on a Windows Form").
Write your XML string to a temporary file, and then point IE at it.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

using AxSHDocVw;

namespace BrowserView
{
public class MainForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;

private AxWebBrowser browser;

public MainForm()
{
InitializeComponent();

string path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolde r.Personal),
"foo.xml");

DisplayFile(path);
}

private void DisplayFile(string path)
{
browser = new AxWebBrowser();
browser.BeginInit();
browser.Dock = DockStyle.Fill;
Controls.Add(browser);
browser.EndInit();

browser.TitleChange += new DWebBrowserEvents2_TitleChangeEventHandler(browser _TitleChange);

Cursor currentCursor = Cursor.Current;
try
{
Cursor.Current = Cursors.WaitCursor;

Uri uri = new Uri("file://" + path);

object arg1 = 0; object arg2 = ""; object arg3 = ""; object arg4 = "";
browser.Navigate(uri.ToString(), ref arg1,ref arg2,ref arg3,ref arg4);
}
catch (Exception e)
{
MessageBox.Show(e.Message + "\n" + e.StackTrace, "Navigation failure");
}
finally
{
Cursor.Current = currentCursor;
}
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(840, 525);
this.Name = "MainForm";
this.Text = "MainForm";

}
#endregion

private void browser_TitleChange(object sender, DWebBrowserEvents2_TitleChangeEvent e)
{
Text = e.text;
}

[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
}
}

Enjoy,
Greg
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: techy techno | last post by:
Hii Just wanted to know how can I decorate my texboxes and Listmenu which is called from a JS file using the following code below: document.write("<SELECT NAME='cur2' ONCHANGE='cconv1();'>");...
2
by: Brett Baisley | last post by:
Hello I have a block of html code that I want to run by calling a javascript function to print it. Its basically a table with menu items in it that is the same for many pages, and instead of...
2
by: Edward | last post by:
The below code builds 2 tables 4 rows by 4 cols. All cells have checkboxes. When checked, the checkboxes in the first column automatically check the remainder of the check boxes in the same row. ...
1
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff...
12
by: Kepler | last post by:
How do you get the height of the client browser in IE? Both document.body.clientHeight and document.body.offsetHeight return the height of the document. If the page is long and there's a vertical...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
5
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate...
6
by: therig | last post by:
I'm having issues, I've spent many hours searching and I'm a noob at javascript, any help will be greatly appreciated. I keep getting the following error: Error: document.forms.sec11_A has no...
4
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.