我有一个xml文件如下
<ScriptFileNames>
<SqlEye>
<ScriptFile Name='_ws_CommandHistory_AllHistory.sql' Type='SP' SqlEyeAnalysisTime='00:00:01.7817594' FxCopAnalysisTime='00:00:00.2253670' FxCopWarningCount='0' SqlEyeWarningCount='2'>
<SqlEyeWarnings>
<SqlEyeWarning message='SD004: Check for existence object then Drop statement before create statement' />
<SqlEyeWarning message='SP001: Set NoCount statement missing or it should be ON.' />
</SqlEyeWarnings>
</ScriptFile>
</SqlEye>
</ScriptFileNames>
我希望输出是
FileName WarningMessage
格式
例如
_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.
我的尝试
string input = @"<ScriptFileNames>
<SqlEye>
<ScriptFile Name='_ws_CommandHistory_AllHistory.sql' Type='SP' SqlEyeAnalysisTime='00:00:01.7817594' FxCopAnalysisTime='00:00:00.2253670' FxCopWarningCount='0' SqlEyeWarningCount='2'>
<SqlEyeWarnings>
<SqlEyeWarning message='SD004: Check for existence object then Drop statement before create statement' />
<SqlEyeWarning message='SP001: Set NoCount statement missing or it should be ON.' />
</SqlEyeWarnings>
</ScriptFile>
</SqlEye>
</ScriptFileNames>";
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();
我还有我更多的部分
<SqlEyeRemarks>
<SqlEyeRemark message='SD001: Set QuotedIdentifier ON statement is missing or order mismatch or it should be ON.' />
<SqlEyeRemark message='SD002: Set AnsiiNullsOn ON statement is missing or order mismatch or it should be ON.' />
<SqlEyeRemark message='SD009: Missing or order mismatch of Grant statement.' />
</SqlEyeRemarks>
我怎样才能让他们在一起?