【问题标题】:How to convert xelement to a string in c#?如何在c#中将xelement转换为字符串?
【发布时间】:2020-02-18 08:09:48
【问题描述】:

我有一个类似的错误

== 不能应用于 string 和 xelement 类型的操作数

.这里我比较

item.Element("APINumber").Value == apiitem

这给出了错误。任何人都可以通过进行任何转换或其他事情来帮助纠正此错误

var apilist = from first in txrrc
              join second in drill
              on first.Element("APINumber").Value 
              equals second.Element("APINumber").Value
                           select first;
IEnumerable<XElement> items = from item in xml2.Descendants()
                .Elements("DrillingPermit")
                where item.Element("APINumber").Value == apiitem                                                  
                select (XElement)item;

【问题讨论】:

  • 你能分享你的xml吗?可能你需要使用apiitem.Element("APINumber").Value

标签: c# xml list linq xelement


【解决方案1】:

这里只是一个猜测,因为我不知道 apiitem 类型虽然因为 .Value 是字符串,所以类型是 XElement

item.Element("APINumber").Value == apiitem.Value

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    相关资源
    最近更新 更多