Anjana Jain
Anjana Jain

Reputation: 43

How to convert xelement to a string in c#?

I have an error like

== cannot be applied to operands of type string and xelement

.Here I am comparing

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

which gives error. Can anyone help to correct this error by doing any conversion or something

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;

Upvotes: 2

Views: 293

Answers (1)

Athanasios Kataras
Athanasios Kataras

Reputation: 26342

Just a guess here as I don't know the apiitem type though since .Value is string, then the type is XElement

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

Upvotes: 1

Related Questions