Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# Web Service Client xml browser display

Status
Not open for further replies.

JackBurton07

IS-IT--Management
Oct 17, 2007
75
0
0
GB
Hi there

Im new to web services and am trying to set up a web client form in asp.net/VS 2005 that reads stock symbol and displays the relevant stock information from the web service. I can get the stock data pulled from the web service but when is displayed in the broswer its just all along one line. Im not sure how I can put it into a table to make it more readable. I reserached maybe I need to use a data grid however I dont know what kind of code to use...


Please help! Here's my code for the form:



using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;



public partial class stockfolder_Default : System.Web.UI.Page
{

StockWebService.StockQuote ws;
protected void Page_Load(object sender, EventArgs e)
{

Page.RegisterHiddenField("__EVENTTARGET", "Button1");
ws = new StockWebService.StockQuote();

}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Label2 .Text = ws.GetQuote(TextBox1.Text);

}

catch
{
Label2.Text = "Invalid Ticker Symbol";
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{

}
}

And I'm using for the web service.

Thanks

Jack
 
the service returns the data in xml. you need to parse the data for display. to do this you have a few options.
1. load xml into xmldocument and navigate the structure using xpath queries.
2. use xml in combination with xslt and render to the form.
3. parse the xml into a custom dto object and display the data.

if you want to display this dat for readonly display option 2 would probally be best.
if you want the user to modify the information after it's loaded option 1 is easiest.
if this information will be used across many areas of the application, or your are using automated testing option 3 would be best.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Code:
XmlDocument doc = new XmlDocument();
doc.LoadXml(GetXmlFromWebService());
...

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top