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!

Web Service XML

Status
Not open for further replies.

JackBurton07

IS-IT--Management
Oct 17, 2007
75
GB
Hi I want to properly display a webservice xml data in an application but i keep getting: illegal characters in path error

what am i doing wrong?

public Form1()
{
InitializeComponent();
}
WSREF.StockQuote ws;

private void Form1_Load(object sender, EventArgs e)
{

ws = new WSREF.StockQuote();
}

private void button1_Click(object sender, EventArgs e)
{

string url = ws.GetQuote(txtInput.Text);


WebClient c = new WebClient();
string xml = ASCIIEncoding.Default.GetString(c.DownloadData(url));
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
foreach (XmlNode node in doc.SelectNodes("/Stock"))
Trace.WriteLine(node.InnerText);



The XML returned data from the webservice is :

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="<Last>176.70</Last><Date>2/28/2008</Date><Time>4:01pm</Time><Change>-4.10
</Change><Open>180.28</Open><High>180.28</High><Low>175.57</Low><Volume>
8828201</Volume><MktCap>69.957B</MktCap><PreviousClose>180.80
</PreviousClose><PercentageChange>-2.27%</PercentageChange><AnnRange>
157.38 - 250.70</AnnRange><Earns>24.733</Earns><P-E>7.31</P-E><Name>
GOLDMAN SACHS GRP</Name></Stock></StockQuotes></string>
 
my guess is "/Stock" is what's breaking. try some of these vairations:
@"/Stock"
"//Stock"

my other guess is the percent symbol (&) within the xml itself is causing a problem. Is this a 3rd party service, or did you/your team design this service. services are meant to pass data only. adding % is a formmatting decision which is not necessary. this should be handled by the presentation.

If it's a 3rd party service you can't do much about it. if it's your service. you should remove all formatting from the xml and return only the raw data.

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

Part and Inventory Search

Sponsor

Back
Top