小编Spi*_*del的帖子

如何在可以是XElement或XAttribute时强制转换XPathEvalute?

所以我有这个代码:

List<PriceDetail> prices =
                (from item in xmlDoc.Descendants(shop.DescendantXName)
                 select new PriceDetail
                 {
                     Price = GetPrice(item.Element(shop.PriceXPath).Value),
                     GameVersion = GetGameVersion(((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value, item.Element(shop.PlatformXPath).Value),
                     Shop = shop,
                     Link = item.Element(shop.LinkXPath).Value,
                     InStock = InStock(item.Element(shop.InStockXPath).Value)
                 }).ToList<PriceDetail>();
Run Code Online (Sandbox Code Playgroud)

我遇到的问题是这段代码:

((IEnumerable)item.XPathEvaluate(shop.TitleXPath)).Cast<XAttribute>().First<XAttribute>().Value
Run Code Online (Sandbox Code Playgroud)

有时来自XPathEvaluate的对象可能是XElement,然后转换不起作用.所以我需要的是一个适用于XAttribute和XElement的Cast.

有什么建议吗?

.net c# xml xpath

10
推荐指数
3
解决办法
6899
查看次数

Django为什么要使用我的服务器IP向我发送无效的HTTP_HOST标头?

因此Django向我发送了以下信息:

[Django] ERROR: Invalid HTTP_HOST header: '<my server IP here>'.You may need to add u'<my server IP here>' to ALLOWED_HOSTS.

No stack trace available

Request repr() unavailable.
Run Code Online (Sandbox Code Playgroud)

问题是...您无法使用服务器IP访问我的网站,因为我只允许ALLOWED_HOST设置中的域。

所以我该怎么做?

编辑:我正在使用Nginx-> Gunicorn。有时仅会发生此错误,例如每周1-2次。

django logging nginx

3
推荐指数
1
解决办法
2413
查看次数

标签 统计

.net ×1

c# ×1

django ×1

logging ×1

nginx ×1

xml ×1

xpath ×1