how can I get the ID value of XML Customer tag

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

polachan

Guest
I am trying to get the ID value of an XML file into the string


var _xmlresult = new xmlResult();

string docxml = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\" + sqlxml;
doc.Load(xml);

XmlNodeList subjectList = doc.GetElementsByTagName("CUSTOMER");

foreach (var child in subjectList)
{
if (child is XmlNode)
{
var element = (XmlNode)child;
if (element.HasChildNodes)
{
_xmlresult = GetSQL(element);
//result.AddRange(GetSQL(element));
}
}
}



public static xmlResult GetSQL(XmlNode element)
{
var _resultxml = new xmlResult();


if (element.name='Customer')

{

_resultxml.tagid = ' store the id value of the xml it should be 'CUSTOMER1 when it read for the Customer1
}

}




public class xmlResult
{
public string tagid;
public List<string> listSql;
}


My XML format

<?xml version="1.0" encoding="utf-8" ?>
<STATEMENT>
<CUSTOMER ID = "CUSTOMER1">
<SQL ID="SQLS1">
<!--SELECT * FROM CUSTOMER WHERE CODE = '123'-->
</SQL>
<SQL ID="SQLS2">
<!--SELECT * FROM CUSTOMER WHERE CODE = '567'-->
</SQL>
<Address>test@gmail.com</Address>
<Address>test1@gmail.com</Address>
<Address></Address>
<MailSubject>Please find statement</MailSubject>
<MailBody>Please find statement</MailBody>

<FILENAME>file1</FILENAME>

</CUSTOMER>
<CUSTOMER ID = "CUSTOMER2">
<SQL ID="SQLS">
<!--
<!--SELECT * FROM CUSTOMER WHERE CODE = '1234'-->
-->
</SQL>
<Address>test@gmail.com</Address>
<Address>test1@gmail.com</Address>
<Address></Address>
<MailSubject>Please find statement</MailSubject>
<MailBody>Please find statement</MailBody>
<FILENAME>file2</FILENAME>

</CUSTOMER>
</STATEMENT>








polachan

Continue reading...
 
Back
Top