Parse XML Elements with LINQ?

The nodes are all in the w3.org/2005/Atom namespace. Therefore you need to prefix the queries with this namespace, otherwise the query tries to find those elements in the empty namespace.

Up vote 1 down vote favorite share g+ share fb share tw.

I have this xml. Name. Gr 2011-07-23?

,? ,? (2006)?

?.? «? »? :... 2011-07-23T12:54:00+03:00 I want to parse some of the elements inside .

For that I use the following LINQ code. Var list = from y in xelement. Descendants("entry") select new Update() { Title = y.

Element("title"). Value, Pubdate = y. Element("published").

Value, Descr = y. Element("content"). Value, Link = y.

Element("link"). Attribute("href"). Value }; But it does not work.

Can anyone tell me what am I doing wrong? C# linq-to-xml link|improve this question edited Jul 23 '11 at 13:44svick28.4k62060 asked Jul 23 '11 at 10:22Kwstas263 17% accept rate.

The nodes are all in the w3.org/2005/Atom" rel="nofollow">w3.org/2005/Atom namespace. Therefore you need to prefix the queries with this namespace, otherwise the query tries to find those elements in the empty namespace. XNamespace atom = "w3.org/2005/Atom" rel="nofollow">w3.org/2005/Atom"; var list = from y in xelement.

Descendants(atom+"entry") select new Update() { Title = y. Element(atom+"title"). Value, Pubdate = y.

Element(atom+"published"). Value, Descr = y. Element(atom+"content").

Value, Link = y. Element(atom+"link"). Attribute("href").

Value }.

E.g. . – James Jul 23 '11 at 11:37 No.

The root XML element (feed) redefines the empty/default namespace prefix with the xmlns attribute. Therefore, all elements starting with the one on which the xmlns is defined are in that namespace (unless redefined). – Lucero Jul 23 '11 at 11:58.

In your XML example, there is missing "feed" endtag and you are using an element "content", but I guess "summary" is correct.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions