How to loop all XML attributes without knowing the element

How do i loop all xml attribute without knowing the element name

here is my sample xml

<dd l="11243" t="641" r="11653" b="1004">
  <para l="11276" t="768" r="11620" b="941" alignment="left" spaceBefore="79" lsp="exactly" lspExact="273" language="en">
    <ln l="11342" t="768" r="11554" b="941" baseLine="939" underlined="none" subsuperscript="none" fontSize="1250" fontFace="Times New Roman" fontFamily="roman" fontPitch="variable" spacing="19" foreColor="545766">
      <wd l="11342" t="768" r="11554" b="941">
        <ch l="11342" t="768" r="11453" b="936">4</ch>
        <ch l="11472" t="768" r="11554" b="941" conf="10">3</ch>
      </wd>
    </ln>
  </para>
</dd>

and here is my code

XDocument columndoc = XDocument.Parse(reader);
foreach (var node in columndoc.Descendants("para").ToList())
{
}

but i don't want to loop all elements and read its l, t,r,b tag.

so how can i loop using its attribute. thank you

Jon Skeet
people
quotationmark

Just omit the "para" argument from Descendants() - that will obtain all the descendant elements. You can then call Attributes() (which in this case is an extension method on IEnumerable<XElement>) to obtain all the attributes from all those elements.

var allAttributes = doc.Descendants().Attributes().ToList();

people

See more on this question at Stackoverflow