-1
我試圖用這個網址...如何將URL轉換爲XML
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());
}