How to solve Error CS1935 IEnumerable<XElement>

  • Thread starter Thread starter CY_Chen
  • Start date Start date
C

CY_Chen

Guest
I try to load xml and get certain data

Here is my config.xml content

<CONFIG xmlns:xdi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="XML Schema" FrameWidth="400" FrameHeight="200">
<Frames>
<FRAME FrameName="Frame0">
<Frame_Elements>
<Frame_Element><!--Frame_Element[0]-->
<Basic><!--Basic[0]-->
<Id>0</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[0]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>f.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[1]-->
<Basic><!--Basic[1]-->
<Id>1</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[1]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>large.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[2]-->
<Basic><!--Basic[2]-->
<Id>2</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[2]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>medium.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[0]-->
<Basic><!--Basic[3]-->
<Id>3</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[3]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>small.png</BaseFileName>
</Base>
</Frame_Element>
</Frame_Elements>
</FRAME>
<FRAME FrameName="Frame1">
<Frame_Elements>
<Frame_Element><!--Frame_Element[4]-->
<Basic><!--Basic[4]-->
<Id>4</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[4]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>Main.png</BaseFileName>
</Base>
</Frame_Element>
<Frame_Element><!--Frame_Element[5]-->
<Basic><!--Basic[5]-->
<Id>5</Id>
<Uid>0</Uid>
</Basic>
<Base><!--Base[5]-->
<BaseFilePath>C:/Image</BaseFilePath>
<BaseFileName>icon.png</BaseFileName>
</Base>
</Frame_Element>
</Frame_Elements>
</FRAME>
</CONFIG>

I try to get Frame0 Frame1

So use below code to get

XElement config = XElement.Load(filePath);
IEnumerable<XElement> frame = from element in config.Elements("FRAME")
where element.Attribute("FrameName")
select element;


I include

using System.Xml.Linq;
using System.Collections.Generic;


But I get error

Severity Code Description Project File Line Suppression State
Error CS1935 Could not find an implementation of the query pattern for source type 'IEnumerable<XElement>'. 'Where' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'? C:\OpenXML.cs 19 Active1487438.png

How to solve this?

Thanks

Continue reading...
 
Back
Top