Hi Raj,
Thanks for your response ,I have applied your solution on my previous post but i wanted to use XmlDocument to load the XML file instead of XDocument, the below is my XML file
<results>
<response mode="all" value=""/>
<statements>
<table table_name="Year To Date (Lumber/TVM Paint are included in Total Sales)">
<table_col_headings col_heading_4="Thru Mar 2016" col_heading_5="Var %" col_heading_6="Thru Mar 2015" col_heading_7="Var %" col_heading_8="Thru Mar 2014" />
<table_rows>
<table_row row_caption="Stock" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Event" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Handled" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Direct Ship" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Total Sales" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Lumber" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="TVM Paint" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
</table_rows>
</table>
<table table_name="Period End (Lumber/TVM Paint are included in Total Sales)">
<table_col_headings col_heading_4="Mar 2016" col_heading_5="Var %" col_heading_6="Mar 2015" col_heading_7="Var %" col_heading_8="Mar 2014" />
<table_rows>
<table_row row_caption="Stock" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Event" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Handled" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Direct Ship" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Total Sales" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="Lumber" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
<table_row row_caption="TVM Paint" col_data4="0" col_data5="0" col_data6="0" col_data7="0" col_data8="0" />
</table_rows>
</table>
</statements>
</results>
I have tried like this but i'm not getting all the results i'm unable to loop through the attributes ,
XmlDocument xmlDoc = new XmlDocument();
string StatementReportResponseXml = reportService.GetStatementReportInfo(storeId, currentMonth.ToString()).Result;
xmlDoc.LoadXml(StatementReportResponseXml);
var statementsReport = new StatementInfoViewModel();
//check for a an "error" node within the results
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("ns", "http://wsdev.truserv.com/oraclewebservice/oraclemdb.asmx");
XmlNode resultNode = xmlDoc.SelectSingleNode("results", nsmgr);
XmlNode userNodeTable = resultNode.SelectSingleNode("statements/table", nsmgr);
if (userNodeTable != null)
{
statementsReport.TableName = userNodeTable.Attributes["table_name"] != null ? userNodeTable.Attributes["table_name"].Value : string.Empty;
XmlNode userNodeColumnHeaders = resultNode.SelectSingleNode("statements/table/table_col_headings", nsmgr);
statementsReport.CoulmnHeading4 = userNodeColumnHeaders.Attributes["col_heading_4"] != null ? userNodeColumnHeaders.Attributes["col_heading_4"].Value : string.Empty;
statementsReport.CoulmnHeading5 = userNodeColumnHeaders.Attributes["col_heading_5"] != null ? userNodeColumnHeaders.Attributes["col_heading_5"].Value : string.Empty;
statementsReport.CoulmnHeading6 = userNodeColumnHeaders.Attributes["col_heading_6"] != null ? userNodeColumnHeaders.Attributes["col_heading_6"].Value : string.Empty;
statementsReport.CoulmnHeading7 = userNodeColumnHeaders.Attributes["col_heading_7"] != null ? userNodeColumnHeaders.Attributes["col_heading_7"].Value : string.Empty;
statementsReport.CoulmnHeading8 = userNodeColumnHeaders.Attributes["col_heading_8"] != null ? userNodeColumnHeaders.Attributes["col_heading_8"].Value : string.Empty;
XmlNode userNodeTableRows = resultNode.SelectSingleNode("statements/table/table_rows/table_row", nsmgr);
statementsReport.Stock = userNodeTableRows.Attributes["row_caption"] != null ? userNodeTableRows.Attributes["row_caption"].Value : string.Empty;
}
Basically i need an output which i have shared as an attachment kindly provide me a solution
Download source fileJoin Hands Change lives
Thanks & Regards
Straight Edge Society
Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator