EDN Admin
Well-known member
<AnswerSet> <br/>
<Answer name="es/21-9-c <br/>
<TextValue>420 Quincy St.</TextValue><br/>
</Answer><br/>
<Answer name="rptmc/programtype <br/>
<MCValue><br/>
<SelValue>VS</SelValue><br/>
</MCValue><br/>
</Answer><br/>
<Answer name="programtype <br/>
<MCValue><br/>
<SelValue>AS</SelValue><br/>
<SelValue>BS</SelValue><br/>
<SelValue>CS</SelValue><br/>
<SelValue>Ron</SelValue><br/>
<SelValue>Deepak</SelValue><br/>
<SelValue>Nelson</SelValue><br/>
</MCValue>
<br/>
</Answer> <br/>
</AnswerSet><br/>
<pre class="prettyprint public class AnswerFile<br/> {<br/> public string txt_DSCL_COLUMN_NAME { get; set; }<br/> public string int_DSCL_VARIABLE_TYPE_ID { get; set; } <br/> public DateTime dat_DSCL_CREATED_DATE { get; set; }<br/> public string txt_DSVL_VALUE { get; set; } <br/> } <br/> string getXmlPath = @"CA_PortalClientFiles3977034278DownloadedDataSets10-16-12Transformed";
System.Collections.Generic.List<FileInfo> _theFiles;
_theFiles = Utility.GetFiles(getXmlPath, "xml");
int totalFiles = _theFiles.Count;
foreach (FileInfo AnswerFileInfo in _theFiles)
{
XDocument obAnsFile;
string AnswerFileName = AnswerFileInfo.Name;
obAnsFile = new XDocument();
obAnsFile = XDocument.Load(AnswerFileInfo.FullName);
string n;
IEnumerable<AnswerFile> Answers = (from e in obAnsFile.Descendants("Answer")
select new AnswerFile
{
txt_DSCL_COLUMN_NAME = e.Attribute("name").Value,
txt_DSVL_VALUE = e.Value,
dat_DSCL_CREATED_DATE = DateTime.Now,
int_DSCL_VARIABLE_TYPE_ID = e.FirstNode != null ? ((XElement)e.FirstNode).Name.LocalName : "hello",
}).ToList(); [/code]
The Output I want is should be in this format
<pre class="prettyprint For this <Answer name="es/21-9-c <br/> <TextValue>420 Quincy St.</TextValue><br/></Answer><br/> txt_DSCL_COLUMN_NAME ="es/21-9-c"<br/>int_DSCL_VARIABLE_TYPE_ID ="TextValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="420 Quincy St." -------------------------------------------- <Answer name="rptmc/programtype <br/> <MCValue><br/> <SelValue>VS</SelValue><br/> </MCValue><br/> </Answer> <pre class="prettyprint txt_DSCL_COLUMN_NAME ="rptmc/programtype"<br/>int_DSCL_VARIABLE_TYPE_ID ="MCValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="VS"[/code] <Answer name="programtype <br/> <MCValue><br/> <SelValue>AS</SelValue><br/> <SelValue>BS</SelValue><br/> <SelValue>CS</SelValue><br/> <SelValue>Ron</SelValue><br/> <SelValue>Deepak</SelValue><br/> <SelValue>Nelson</SelValue><br/> </MCValue> <br/> </Answer> <pre class="prettyprint <pre class="prettyprint txt_DSCL_COLUMN_NAME ="programtype"<br/>int_DSCL_VARIABLE_TYPE_ID ="MCValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="VS|BS|CS|Ron|Deepak|Nelson"[/code][/code] Kindly let me know if the things are not clear [/code]
View the full article
<Answer name="es/21-9-c <br/>
<TextValue>420 Quincy St.</TextValue><br/>
</Answer><br/>
<Answer name="rptmc/programtype <br/>
<MCValue><br/>
<SelValue>VS</SelValue><br/>
</MCValue><br/>
</Answer><br/>
<Answer name="programtype <br/>
<MCValue><br/>
<SelValue>AS</SelValue><br/>
<SelValue>BS</SelValue><br/>
<SelValue>CS</SelValue><br/>
<SelValue>Ron</SelValue><br/>
<SelValue>Deepak</SelValue><br/>
<SelValue>Nelson</SelValue><br/>
</MCValue>
<br/>
</Answer> <br/>
</AnswerSet><br/>
<pre class="prettyprint public class AnswerFile<br/> {<br/> public string txt_DSCL_COLUMN_NAME { get; set; }<br/> public string int_DSCL_VARIABLE_TYPE_ID { get; set; } <br/> public DateTime dat_DSCL_CREATED_DATE { get; set; }<br/> public string txt_DSVL_VALUE { get; set; } <br/> } <br/> string getXmlPath = @"CA_PortalClientFiles3977034278DownloadedDataSets10-16-12Transformed";
System.Collections.Generic.List<FileInfo> _theFiles;
_theFiles = Utility.GetFiles(getXmlPath, "xml");
int totalFiles = _theFiles.Count;
foreach (FileInfo AnswerFileInfo in _theFiles)
{
XDocument obAnsFile;
string AnswerFileName = AnswerFileInfo.Name;
obAnsFile = new XDocument();
obAnsFile = XDocument.Load(AnswerFileInfo.FullName);
string n;
IEnumerable<AnswerFile> Answers = (from e in obAnsFile.Descendants("Answer")
select new AnswerFile
{
txt_DSCL_COLUMN_NAME = e.Attribute("name").Value,
txt_DSVL_VALUE = e.Value,
dat_DSCL_CREATED_DATE = DateTime.Now,
int_DSCL_VARIABLE_TYPE_ID = e.FirstNode != null ? ((XElement)e.FirstNode).Name.LocalName : "hello",
}).ToList(); [/code]
The Output I want is should be in this format
<pre class="prettyprint For this <Answer name="es/21-9-c <br/> <TextValue>420 Quincy St.</TextValue><br/></Answer><br/> txt_DSCL_COLUMN_NAME ="es/21-9-c"<br/>int_DSCL_VARIABLE_TYPE_ID ="TextValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="420 Quincy St." -------------------------------------------- <Answer name="rptmc/programtype <br/> <MCValue><br/> <SelValue>VS</SelValue><br/> </MCValue><br/> </Answer> <pre class="prettyprint txt_DSCL_COLUMN_NAME ="rptmc/programtype"<br/>int_DSCL_VARIABLE_TYPE_ID ="MCValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="VS"[/code] <Answer name="programtype <br/> <MCValue><br/> <SelValue>AS</SelValue><br/> <SelValue>BS</SelValue><br/> <SelValue>CS</SelValue><br/> <SelValue>Ron</SelValue><br/> <SelValue>Deepak</SelValue><br/> <SelValue>Nelson</SelValue><br/> </MCValue> <br/> </Answer> <pre class="prettyprint <pre class="prettyprint txt_DSCL_COLUMN_NAME ="programtype"<br/>int_DSCL_VARIABLE_TYPE_ID ="MCValue"<br/>dat_DSCL_CREATED_DATE="26/10/2012"<br/>txt_DSVL_VALUE ="VS|BS|CS|Ron|Deepak|Nelson"[/code][/code] Kindly let me know if the things are not clear [/code]
View the full article