Hi I am new to LINQ
I have an xml in the following format
"<root>"
"<page>"
"<title>text</title>"
"<text attrib1="1">some text</text>"
"<text attrib1="2">some text</text>"
"<text attrib1="3">some text</text>"
"<text attrib1="4">some text</text>"
"</page>"
"<page>"
"<title>text</title>"
"<text attrib1="1">some text</text>"
"<text attrib1="2">some text</text>"
"<text attrib1="3">some text</text>"
"<text attrib1="4">some text</text>"
"</page>"
"</root>"
ignore " "
now i want the resultant xml like this
"<root>"
"<title>text</title>"
"<text attrib1="4">some text</text>"
"<title>text</title>"
"<text attrib1="4">some text</text>"
"</root>"
can this be achieved in one query? I tried the following by using two queries
var titleElms =
from t in allElements
select
new
{
Title = t.Element("title")
};
var textElms =
from t in allText
where (string)t.Attribute("attrib1").Value == "4"
select
t;
I am not happy with it. So is there any other approach? pls help.