\[quote\] Possible Duplicate:
reading double nested xml \[/quote\]I'm trying to read the following XML file\[code\]<Tabellen><Header> <Tables> <Table>SW_RL</Table> <Fields> <Field>KeyVeld</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>ErrorCode</Field> <Type>Alpha</Type> <Size>50</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Description</Field> <Type>Memo</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> </Tables></Header><Header> <Tables> <Table>SW_RH</Table> <Fields> <Field>DocNum</Field> <Type>Numeric</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>PaymentTerms</Field> <Type>Numeric</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>DocDate</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Contract_Start</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Contract_End</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>CardCode</Field> <Type>Alpha</Type> <Size>40</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>CardName</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>BillToAddress</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>ShipToAddress</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>NumAtCard</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>BillingPeriod</Field> <Type>Alpha</Type> <Size>10</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>AdvanceBilling</Field> <Type>Alpha</Type> <Size>10</Size> <SubType>st_none</SubType> </Fields> </Tables></Header>\[/code\]Current code\[code\] XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(directory + "\\Server_Config.xml"); XmlNodeList xmlNodelist = null; XmlNodeList xmlNodelist2 = null; xmlNodelist = xmldoc.SelectNodes("Tabellen/Header/Tables"); foreach (XmlNode mnode in xmlNodelist) { MessageBox.Show(mnode["Table"].InnerText, "ok"); //create table xmlNodelist2 = xmldoc.SelectNodes("Tabellen/Header/Tables/Fields"); foreach (XmlNode mnode2 in xmlNodelist2) { MessageBox.Show(mnode2["Field"].InnerText, "ok"); // create fields } }\[/code\]The general idea is to create 2 tablesTable 1: RL containing 3 fieldsTable 2 :RH containing 12 fieldsBut actually the result is both tables containing 15 fieldsWhat am I doing wrong ??Thanks,Paul
reading double nested xml \[/quote\]I'm trying to read the following XML file\[code\]<Tabellen><Header> <Tables> <Table>SW_RL</Table> <Fields> <Field>KeyVeld</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>ErrorCode</Field> <Type>Alpha</Type> <Size>50</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Description</Field> <Type>Memo</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> </Tables></Header><Header> <Tables> <Table>SW_RH</Table> <Fields> <Field>DocNum</Field> <Type>Numeric</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>PaymentTerms</Field> <Type>Numeric</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>DocDate</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Contract_Start</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>Contract_End</Field> <Type>Date</Type> <Size>0</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>CardCode</Field> <Type>Alpha</Type> <Size>40</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>CardName</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>BillToAddress</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>ShipToAddress</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>NumAtCard</Field> <Type>Alpha</Type> <Size>100</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>BillingPeriod</Field> <Type>Alpha</Type> <Size>10</Size> <SubType>st_none</SubType> </Fields> <Fields> <Field>AdvanceBilling</Field> <Type>Alpha</Type> <Size>10</Size> <SubType>st_none</SubType> </Fields> </Tables></Header>\[/code\]Current code\[code\] XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(directory + "\\Server_Config.xml"); XmlNodeList xmlNodelist = null; XmlNodeList xmlNodelist2 = null; xmlNodelist = xmldoc.SelectNodes("Tabellen/Header/Tables"); foreach (XmlNode mnode in xmlNodelist) { MessageBox.Show(mnode["Table"].InnerText, "ok"); //create table xmlNodelist2 = xmldoc.SelectNodes("Tabellen/Header/Tables/Fields"); foreach (XmlNode mnode2 in xmlNodelist2) { MessageBox.Show(mnode2["Field"].InnerText, "ok"); // create fields } }\[/code\]The general idea is to create 2 tablesTable 1: RL containing 3 fieldsTable 2 :RH containing 12 fieldsBut actually the result is both tables containing 15 fieldsWhat am I doing wrong ??Thanks,Paul