linq drill down statement
linq drill down statement
(OP)
How can I write this to linq
first I'm doing
XElement root = doc.MainDocumentPart.GetXDocument().Root;
then
var query = from c in root.Descendants(W.p) select c;
then
foreach (XElement p in query)
{
XElement pElement = p.Descendants(w + "pStyle").FirstOrDefault() ;
if (pElement != null)
{
string spElement = pElement.Attributes(w + "val").FirstOrDefault().Value as string;
if (strStylesAll.Contains(spElement))
{
if (strStyles.Contains(spElement))
{
strReferenceNumber = strReferenceNumber + 1;
}
else
{ strReferenceNumber = strReferenceNumber; }
strStylesname.Add(spElement + "p" + " " + strReferenceNumber);
// addtoTable(spElement, strReferenceNumber)
}
}}
I know it looks ugly and not
any help would be nice
first I'm doing
XElement root = doc.MainDocumentPart.GetXDocument().Root;
then
var query = from c in root.Descendants(W.p) select c;
then
foreach (XElement p in query)
{
XElement pElement = p.Descendants(w + "pStyle").FirstOrDefault() ;
if (pElement != null)
{
string spElement = pElement.Attributes(w + "val").FirstOrDefault().Value as string;
if (strStylesAll.Contains(spElement))
{
if (strStyles.Contains(spElement))
{
strReferenceNumber = strReferenceNumber + 1;
}
else
{ strReferenceNumber = strReferenceNumber; }
strStylesname.Add(spElement + "p" + " " + strReferenceNumber);
// addtoTable(spElement, strReferenceNumber)
}
}}
I know it looks ugly and not
any help would be nice
RE: linq drill down statement
You say "How can I write this to linq " - but you are already using linq in this code!
Please tell what exactly your code is doing and what it isn't doing and what it is supposed to do.
Cheers,
MakeItSo
“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
RE: linq drill down statement
RE: linq drill down statement
CODE
Its really hard to be sure given there are missing pieces about what you are doing, but this 'should' do the same thing.. I think...
CODE --> C#