Note that there are some explanatory texts on larger screens.

plurals
  1. PODifficulty in reading XML values using XDocument
    primarykey
    data
    text
    <p>I have an xml file as under</p> <pre><code>&lt;ScriptFileNames&gt; &lt;SqlEye&gt; &lt;ScriptFile Name='_ws_CommandHistory_AllHistory.sql' Type='SP' SqlEyeAnalysisTime='00:00:01.7817594' FxCopAnalysisTime='00:00:00.2253670' FxCopWarningCount='0' SqlEyeWarningCount='2'&gt; &lt;SqlEyeWarnings&gt; &lt;SqlEyeWarning message='SD004: Check for existence object then Drop statement before create statement' /&gt; &lt;SqlEyeWarning message='SP001: Set NoCount statement missing or it should be ON.' /&gt; &lt;/SqlEyeWarnings&gt; &lt;/ScriptFile&gt; &lt;/SqlEye&gt; &lt;/ScriptFileNames&gt; </code></pre> <p>I want the output to be</p> <p><code>FileName WarningMessage</code> format</p> <p>e.g. </p> <pre><code>_ws_CommandHistory_AllHistory.sql SD004: Check for existence object then Drop statement before create statement _ws_CommandHistory_AllHistory.sql SP001: Set NoCount statement missing or it should be ON. </code></pre> <p>My attempt</p> <pre><code>string input = @"&lt;ScriptFileNames&gt; &lt;SqlEye&gt; &lt;ScriptFile Name='_ws_CommandHistory_AllHistory.sql' Type='SP' SqlEyeAnalysisTime='00:00:01.7817594' FxCopAnalysisTime='00:00:00.2253670' FxCopWarningCount='0' SqlEyeWarningCount='2'&gt; &lt;SqlEyeWarnings&gt; &lt;SqlEyeWarning message='SD004: Check for existence object then Drop statement before create statement' /&gt; &lt;SqlEyeWarning message='SP001: Set NoCount statement missing or it should be ON.' /&gt; &lt;/SqlEyeWarnings&gt; &lt;/ScriptFile&gt; &lt;/SqlEye&gt; &lt;/ScriptFileNames&gt;"; XDocument doc = XDocument.Parse(input); XElement scriptFileNames = doc.Element("ScriptFileNames"); var xx = (from x1 in scriptFileNames.Element("SqlEye").Elements("ScriptFile") select new { Name = x1.Attribute("Name").Value }).ToList(); </code></pre> <p>I also have I more section</p> <pre><code>&lt;SqlEyeRemarks&gt; &lt;SqlEyeRemark message='SD001: Set QuotedIdentifier ON statement is missing or order mismatch or it should be ON.' /&gt; &lt;SqlEyeRemark message='SD002: Set AnsiiNullsOn ON statement is missing or order mismatch or it should be ON.' /&gt; &lt;SqlEyeRemark message='SD009: Missing or order mismatch of Grant statement.' /&gt; &lt;/SqlEyeRemarks&gt; </code></pre> <p>How can I get them along?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload