我正在尝试使用此网址...
http://www.webservicex.net/stockquote.asmx/GetQuote?Symbol=T
它的作用类似于 XML,但格式不正确,我希望能够使用它以 XML 形式显示它...
这是我现在的代码
protected void btnGetResult_Click(object sender, EventArgs e)
{
XPathNavigator nav;
XmlDocument myXMLDocument = new XmlDocument();
String stockQuote = "http://www.webservicex.net/stockquote.asmx/GetQuote?Symbol=T" + txtInfo.Text;
myXMLDocument.Load(stockQuote);
// Create a navigator to query with XPath.
nav = myXMLDocument.CreateNavigator();
nav.MoveToRoot();
nav.MoveToFirstChild();
do
{
//Find the first element.
if (nav.NodeType == XPathNodeType.Element)
{
//Move to the first child.
nav.MoveToFirstChild();
//Loop through all the children.
do
{
//Display the data.
txtResults.Text = txtResults.Text + nav.Name + " - " + nav.Value + Environment.NewLine;
} while (nav.MoveToNext());
}
} while (nav.MoveToNext());
}