Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm trying to read an xml file and display to datagridview. while doing i'm able to display header items only child nodes are missing

xml file

XML
-<EclipseHeader OpportunityID="" CurrencyCode="AD" PriceTerm="DF" Country="AU" OrigApplication="SBW" SupplyChain="BTCO" ConfigID="10001" SKU="TBD" NetPrice="0" ConfigName="StoreEasy 1640 - Tape Options - 25-2-2015/HP StoreEasy 1640 16TB SAS Storage #3">


-<EclipseLineItems>

<EclipseLineItem NetPrice="17630" Level="1" IntegrationGroupCode="20101" Description="HP StoreEasy 1640 16TB SAS Storage" Quantity="1" ProductNumber="E7W82A" TagText="NA"/>

<EclipseLineItem NetPrice="0" Level="1" IntegrationGroupCode="20101" Description="HP 4Y 4 hr 24x7 Proactive Care SVC" Quantity="1" ProductNumber="H1K92A4" TagText="NA"/>

<EclipseLineItem NetPrice="3989" Level="2" IntegrationGroupCode="20101" Description="HP StoreEasy 1440/1640 Support" Quantity="1" ProductNumber="H1K92A4 SPV" TagText="NA"/>

<EclipseLineItem NetPrice="0" Level="1" IntegrationGroupCode="20101" Description="HP Installation Service" Quantity="1" ProductNumber="HA113A1" TagText="NA"/>

<EclipseLineItem NetPrice="2625" Level="2" IntegrationGroupCode="20101" Description="HP StoreEasy 1000 3000 Install SVC" Quantity="1" ProductNumber="HA113A1 5AM" TagText="NA"/>

<EclipseLineItem NetPrice="439" Level="1" IntegrationGroupCode="20101" Description="HP H221 PCIe 3.0 SAS HBA" Quantity="1" ProductNumber="729552-B21" TagText="NA"/>

</EclipseLineItems>

</EclipseHeader>




my code


OpenFileDialog openfiledialog2 = new OpenFileDialog();
if (openfiledialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
this.txtXML.Text = openfiledialog2.FileName;
}

DataSet ds = new DataSet();
string xmlfile = txtXML.Text;
ds.ReadXml(xmlfile);
dgvExcelRResult.DataSource = ds.Tables[0];
Posted
Comments
Sinisa Hajnal 5-Mar-15 6:07am    
Did you try looking what is contained in your dataset? My guess would be that you have another table containing items...
Member 10371894 5-Mar-15 6:28am    
Only header file -<eclipseheader opportunityid="" currencycode="AD" priceterm="DF" country="AU" origapplication="SBW" supplychain="BTCO" configid="10001" sku="TBD" netprice="0" configname="StoreEasy 1640 - Tape Options - 25-2-2015/HP StoreEasy 1640 16TB SAS Storage #3"> is apperaing in datagridview
Sinisa Hajnal 5-Mar-15 7:25am    
That is not what I asked. I asked if you checked the dataset. The grid will show only header because you're setting datasets first table as its datasource (which is the header). Put a breakpoint on DataSource line and check the datasets table count.

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900