3

I have some XML like this:

<Section xmlns=\"http:schemas.microsoft.com/winfx/2006/xaml/presentation\"> <Paragraph FontSize=\"12\" FontFamily=\"Arial\" Foreground=\"#FF000000\" FontWeight=\"Normal\" FontStyle=\"Normal\" FontStretch=\"Normal\" TextAlignment=\"Left\"> <Run FontWeight=\"Normal\" Text=\"space \" /> </Paragraph> </Section>

Is there a way to get a collection of all the FontWeight attributes, all the FontSize attributes, etc., regardless of the parent element?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Number8
  • 12,322
  • 10
  • 44
  • 69

1 Answers1

7

Assuming you have XDocument doc = XDocument.Load("file.xml") you can get all attributes with doc.Descendants().Attributes() or all attributes of a certain name with e.g. doc.Descendants().Attributes("FontSize").

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110