how to read the email address of the xml file selected node, Please help urgent

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

polachan

Guest
Hi

I am writng the program to send the statement to customers writing the sql query using an xml file. Each customer part is separated by Customer attribute ID for example Customer1 and Customer2

My sample 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>

Now I am trying to get all the email address under the tag <EmailAddress> in to the List<string> variable EmailAddressList stored under each customer ID. So I am trying to set all email address and MailSubject into the corresponsing variable. My code is given below


public class xmlResult
{
public string Tagid;
public List<string> ListSql;
public List<string> EmailAddressList;
public string fileName;
public string mailBody;

}


public static xmlResult GetSQL(XmlNode element)
{
var result = new List<String>();
var xmlData = new xmlResult();
var x = element.InnerText;
xmlData.Tagid = element.Attributes["ID"].Value;
var attributes = element.Attributes;

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.EmailAddress = How to get all the email address from the selectnode tag <EmailAddress>
xmlData. fileName = ?? //get the filename under FilenameTag


//So xmlAddress.EmailAddress[1] should be test1@gmail.com, xmlAddress.EmailAddress[2] should

be test2@gmail.com . Then next xmlAddress.EmailAddress[1] should be test3@gmail.com,

xmlAddress.EmailAddress[3] should be test4@gmail.com inside the foreach loop of attribute of

CuCustomerID


}

Please help urgent




polachan

Continue reading...
 
Back
Top