Hi
I am currently building an application on .NetCF 3.5 in C#. The
application needs to process xml files. I am thinking about using LINQ
to process XML. I wrote a piece of code to modify the specified
element's value.
XmlReaderSettin gs settings = new
XmlReaderSettin gs();
settings.Confor manceLevel =
ConformanceLeve l.Fragment;
settings.Ignore Whitespace = true;
settings.Ignore Comments = true;
XmlReader reader = XmlReader.Creat e(inboxPath,
settings);
XElement root = XElement.Load(r eader);
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
where el.Element("Mes sageID").Value ==
MsgID
select el;
foreach (XElement el in msgs)
{
el.Element("Mes sageStaus").Set Value(newStatus .ToString());
}
root.Save(inbox Path);
Here is the error message that I received :
msgs.System.Col lections.Generi c.IEnumerator<T Source>.Current 'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
does not contain a definition for 'System' and no extension method
'System' accepting a first argument of type
'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
could be found (are you missing a using directive or an assembly
reference?)
Could someone please explain to me why I get such error message? By
the way I have refference all the necessary dlls. (System.linq;
System.xml.linq )
Is it because I am using compact framework? I've tested this code on
a normal framework. It is working fine.
I am currently building an application on .NetCF 3.5 in C#. The
application needs to process xml files. I am thinking about using LINQ
to process XML. I wrote a piece of code to modify the specified
element's value.
XmlReaderSettin gs settings = new
XmlReaderSettin gs();
settings.Confor manceLevel =
ConformanceLeve l.Fragment;
settings.Ignore Whitespace = true;
settings.Ignore Comments = true;
XmlReader reader = XmlReader.Creat e(inboxPath,
settings);
XElement root = XElement.Load(r eader);
IEnumerable<XEl ementmsgs = from el in
root.Descendant s("Message")
where el.Element("Mes sageID").Value ==
MsgID
select el;
foreach (XElement el in msgs)
{
el.Element("Mes sageStaus").Set Value(newStatus .ToString());
}
root.Save(inbox Path);
Here is the error message that I received :
msgs.System.Col lections.Generi c.IEnumerator<T Source>.Current 'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
does not contain a definition for 'System' and no extension method
'System' accepting a first argument of type
'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
could be found (are you missing a using directive or an assembly
reference?)
Could someone please explain to me why I get such error message? By
the way I have refference all the necessary dlls. (System.linq;
System.xml.linq )
Is it because I am using compact framework? I've tested this code on
a normal framework. It is working fine.
Comment