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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Services XML data won't display correctly

Status
Not open for further replies.

JackBurton07

IS-IT--Management
Oct 17, 2007
75
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
 
It returns this after invoked:

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="<Last>177.25</Last><Date>2/20/2008</Date><Time>4:00pm</Time><Change>0.00
</Change><Open>N/A</Open><High>N/A</High><Low>N/A</Low><Volume>5000</Volume>
<MktCap>70.175B</MktCap><PreviousClose>177.25</PreviousClose>
<PercentageChange>0.00%</PercentageChange><AnnRange>157.38 - 250.70</AnnRange><Earns>24.733</Earns><P-E>7.17</P-E><Name>
GOLDMAN SACHS GRP</Name></Stock></StockQuotes></string>
 
You can read that XML into a dataset. Use the dataset.ReadXML() methold
 
yes but won't the method look for an xml file?

the xml has been generated on the fly from the webservice?

as I said, Im new to all of this so thanks for your patience!
 
it says System.Data.Dataset does not contain a definition for XmlRead
 
you can also use an xmldocument and parse the file using xpath queries.

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

Part and Inventory Search

Sponsor

Back
Top