June: LINQ

Parsing XML cum LINQ

Hic 'a velox ad parse aliquod exemplum adhibitis LINQ  Noun et iniri dulcis, dulce in eo attributa.

Hic 'XML volo parse:

<?xml version="1.0" encoding="utf-8" ?>
<DeafultConfigurationSets>
  <PageLayouts>

    <PageLayout name="xyzzy">
      <Tabs>
        <Tab TabOrder="1" TabLabel="x" SharePointContentType="a" AdditionalConstraints="ac1"/>
        <Tab TabOrder="2" TabLabel="y" SharePointContentType="b" AdditionalConstraints="ac2"/>
      </Tabs>
    </PageLayout>

    <PageLayout name="xyzzy2">
      <Tabs>
        <Tab TabOrder="100" TabLabel="x" SharePointContentType="a" AdditionalConstraints="ac1"/>
        <Tab TabOrder="101" TabLabel="y" SharePointContentType="b" AdditionalConstraints="ac2"/>
        <Tab TabOrder="103" TabLabel="z" SharePointContentType="c" AdditionalConstraints="ac3"/>
      </Tabs>
    </PageLayout>

  </PageLayouts>
</DeafultConfigurationSets>

Cupio ædificare quidam in tabs per runtime parsing supra.  Tabs mea dependet a page layout.  Si est nomen meum, page layout "xyzzy2 'volo ut tunc tabs 100, 101 et 103 (in tabs <PageLayout name = "xyzzy2">).

Hic qui facit LINQ:

= erat allTabs
              ex P in
                  XElement.Parse(theXmlToParse).
                 
Elementorum("PageLayouts").
                  Elementorum("PageLayout")
              ubi (p.Attribute("name").Value.Equals("xyzzy2"))
              ex M in p.Elements("Tabs").Elementorum("Tab")
              m lego;

          Results.Text = string.Empty;

          foreach (ATAB erat in allTabs)
          {
              Results.Text =
                  "Tab Order: " + aTab.Attribute("TabOrder").Valor + " |" +
                  "Tab Label: " + aTab.Attribute("TabLabel").Valor + " | " +
                  "SharePointContentType: " + aTab.Attribute("SharePointContentType").Valor + " | " +
                  "AdditionalConstraints: " + aTab.Attribute("AdditionalConstraints").Valor + "\r";
          }

Superius, variabilis "theXmlToParse" filum est variabilis, sed potest uti oneris() modus in flumine, si libet,.

"Consequitur," label est cum in forma huius Codicis telam exequitur, is vultus amo is:

SNAGHTML11cd2e7c

Non operabatur, quomodo adhuc eventus exstat, Lorem ipsum relinquere elit ita futurum.

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin