how can I get the selectednode attribute into the list<string> variable. Please help

  • Thread starter Thread starter polachan
  • Start date Start date
P

polachan

Guest
Sorry for disturbing you all. This might be the last question from my side to read the xml file

I want to get the SQL ID name into the list string variable. The list string should be stored with SQLS1, SQLS2

My code

foreach (var child in subjectList)
{
if (child is XmlNode)
{
var element = (XmlNode)child;
if (element.HasChildNodes)
{
var attributes = element.Attributes;
xmlData.Tagid = element.Attributes["ID"].Value;
//xmlData = GetSQL(element);
foreach (var item in attributes)
{
string id = element.Attributes["ID"].Value;
xmlData.ListSql =
element
.SelectNodes("SQL/comment()")
.Cast<XmlComment>()
.Select(c => c.Value.Trim())
.ToList();

xmlData.EmailAddressList =
element
.SelectNodes("Address")
.Cast<XmlNode>()
.Select(c => c.InnerText.Trim())
.ToList();
xmlData.mailSubject =
element
.SelectNodes("MailSubject")
.Cast<XmlNode>()
.Select(c => c.InnerText).FirstOrDefault();
xmlData.mailBody =
element
.SelectNodes("MailBody")
.Cast<XmlNode>()
.Select(c => c.InnerText).FirstOrDefault();
xmlData.fileName =
element
.SelectNodes("FileName")
.Cast<XmlNode>()
.Select(c => c.InnerText).FirstOrDefault();
List<string> sheetID =
element
.SelectNodes("SQL")
.Cast<XmlNode>()
.Select(c => c.Attributes("ID")) Here not working ?????
.ToList();




Please help

}
_filename = CreateExcelFile(xmlData, _excelfolder,database);

}
}
}

XML

<?xml version="1.0" encoding="utf-8" ?>
<STATEMENT>
<CUSTOMER ID = "CUSTOMER1">
<SQL ID="SQLS1">
<!-- Select Rate From Product -->
</SQL>
<SQL ID="SQLS2">
<!-- select Qty from Product -->
</SQL>
<Address>test1@gmail.com</Address>
<Address>test2@gmail.com</Address>
<Address></Address>
<MailSubject>Statement</MailSubject>
<MailBody>Please find statement</MailBody>
<FILENAME>Statement2</FILENAME>
</CUSTOMER>
<CUSTOMER ID = "CUSTOMER2">
<SQL ID="SQLS">
<!-- Select Code from Customer -->
</SQL>
<SQL ID="SQLS3">
<!-- select name from supplier -->
</SQL>
<SQL ID="SQLS4">
<!-- select qty from purchase-->
</SQL>

<EmailAddress>test3@gmail.com</Address>
<EmailAddress>test4@gmail.com</Address>
<MailSubject>statement</MailSubject>
<MailBody>Please find statement</MailBody>
<FILENAME>Statement2</FILENAME>
</CUSTOMER>
</STATEMENT>





polachan

Continue reading...
 
Back
Top