如何解决'>'是一个意外的令牌。预期的令牌是''''要么 '''。第1行,第50位这个问题 [英] How to solve the '>' is an unexpected token. The expected token is '"' or '''. Line 1, position 50 this issue
问题描述
大家好,
i我正在尝试使用c#读取xml数据,这里我面临的问题是我无法读取数据。
i我正在尝试实现从雅虎网址获取雅虎贴纸数据并绑定到表格。
数据包含URL并读取该数据并绑定到表格。
i am使用以下代码
Hi All,
i am trying to read xml data using c#,here ia m facing the issue is i am not able to read the data.
i am trying to implement getting yahoo stickers data from yahoo url and bind into table.
The data contains URL and read that data and bind to table.
i am using the below code
string yahooURL = ConnectionStrings.yahooURL;
string symbolList = String.Join("%2C", Quotes.Select(w => "%22" + w.Symbol + "%22").ToArray());
string url = string.Format(yahooURL,symbolList);
XDocument doc = XDocument.Load(url);
XElement results = doc.Root.Element("results");
foreach (Quote quote in Quotes)
{
Watchlist objPC = new Watchlist();
XElement q = results.Elements("quote").First(w => w.Attribute("symbol").Value == quote.Symbol);
objPC.Symbol = quote.Symbol;
objPC.Name = q.Element("Name").Value;
objPC.Price = GetDecimal(q.Element("LastTradePriceOnly").Value);
objPC.Change = GetDecimal(q.Element("Change").Value);
objPC.ChangeInPercent = GetDecimal(q.Element("ChangeinPercent").Value);
objPC.Volume = GetDecimal(q.Element("Volume").Value);
objPC.DaysRange = q.Element("DaysRange").Value;
objPC.YearRange = q.Element("YearRange").Value;
objPC.MarketCapitalization = q.Element("MarketCapitalization").Value;
propClass.Add(objPC);
}
这里我得到的错误是
here i am getting the error is "
'>' is an unexpected token. The expected token is '"' or '''. Line 1, position 50.
以下行我收到错误
the below line i am getting the error
XDocument doc = XDocument.Load(url);
任何机构都可以分享解决方案我。
这是网址
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22FLWS%22) & amp; env = store%3A%2F%2Fdatatables.org%2Falltableswithkeys [ ^ ]
我尝试过:
我在这里得到一个URL那个URL是xml数据来的,但是我无法读取数据。
Any Body can Please share solution to me.
this is the url
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22FLWS%22)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys[^]
What I have tried:
Here i am getting URL and that URL the xml data is coming,But i am not able to read the data.
推荐答案
我猜这个问题是最后的评论。
.Net像XML结构一样有一个根节点(不包括XML头)。
你的由于注释,有3个根节点。
I'd guess the issue is the comments at the end.
.Net like XML structures to have a single root node (Excluding the XML header).
Yours has 3 root nodes because of the comments.
用https替换http。效果很好
Replace http with https. it works great
这篇关于如何解决'>'是一个意外的令牌。预期的令牌是''''要么 '''。第1行,第50位这个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!