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