string Data = reader["ScenarioData"].ToString();
<Scenario Name="Scenario1" Feature="Feature1">
<Steps>
<Step Url="http://google.com"></Step>
</Steps>
</Scenario>
SqlXml sqlXml = reader["ScenarioData"].GetSqlXml();
using (var reader = sqlXml.CreateReader())
{
// Do something with the XML, like maybe
var doc = XDocument.Load(reader);
var url = doc.Element("Scenario")
.Element("Steps")
.Element("Step")
.Attribute("Url")
.Value;
// etc.
}
SqlDataReader reader= cmd.ExecuteReader();
while (reader.Read())
{
.....
// you have already an xml string stocked in data
string data = (string)reader["ScenarioData"];
// parse it
var doc = XDocument.Parse(data);
var step = doc.Descendants("Step").Attributes().FirstOrDefault();
var url = step != null ? step.Value : String.Empty;
......
}
using System.Xml.Linq;
var xml = XElement.Parse(reader["ScenarioData"].ToString());
//assuming there can be multiple <step> elements
var steps = xml.Element("Scenario").Element("Steps").Elements("Step");
var url = steps.First().Attribute("Url").Value;