2011-12-18 10 views
1

からすべての属性のコレクションを取得する方法を私は持っている。このようないくつかのXML:LINQ:すべての要素

<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> 

たfontWeightは、すべての属性のコレクションを取得する方法はあり、全てのFontSize属性、親要素にかかわらず、など?

答えて

2

XDocument doc = XDocument.Load("file.xml")とすると、すべての属性をdoc.Descendants().Attributes()で取得するか、特定の名前のすべての属性をたとえばdoc.Descendants().Attributes("FontSize")

+0

ありがとうございますが、ファイルはありませんが、リッチテキストボックスの文字列があります。 – Number8

+0

入手 - Document.Parse()を使用してください。これは私が探していたものです、ありがとう。 – Number8

関連する問題