I am very New in C# so please don't mind if I ask the silly question.........please cooperate me .
My problem is that suppose I am having very big XML file with lots of child nodes inside, and from them I have to select 2 or 3 child from the list,
What would be the approach to get data in datagrid.
Suppose I am having XML document is like:- in which I have to show only 3 child nodes like BoxName , BoxDesc, Location and Status only then how can we Show these in datagrid.
Please Help me ...........
Nilanka DharmadasaPosted Dec 23, 2009, 7:55 AM
Ankit RathorePosted Dec 23, 2009, 7:28 AM
Have u seen my XML file .........
I have to print from this XMLfile ("BoxName, BoxDesc, Location, StorageDate, StorageUntil, Status")
ok u Got it ......
Please see my XML file at once it is totally different from earlier one which I posted two days before .
Nilanka DharmadasaPosted Dec 23, 2009, 7:18 AM
But you want to do it without hard coding anything. This code doesnt suit your need.
Please understand your requirement and tel it to me. Otherwise both of us will waste our time.
Ankit RathorePosted Dec 23, 2009, 7:11 AM
Actually What kind of approach I am looking for...
just gone through that sample example .........
actually I am not able to understand it properly
Here they are fetching the "productCode" from "inventory.xml" file........
XmlNodeList elements = inventory.SelectNodes("//inventory/items/item");
foreach (XmlElement element in elements) {
string productCode = element.GetAttribute("productCode");
int quantitySold = Int32.Parse(element.GetAttribute("quantity"));
string xPathExpression = "//items/item[@productCode='" + productCode + "']";
XmlElement inventoryItem = (XmlElement)inventory.SelectSingleNode(xPathExpression);
*/
Nilanka DharmadasaPosted Dec 23, 2009, 7:04 AM
Ankit RathorePosted Dec 23, 2009, 6:37 AM
Please just gone through my new XML,
and the code u sent me is not like that which I am looking for ........
Suppose if I have add 100 columns then what happen I am not going to write IF condition for each column.
By this the performance of the program is also reduce.
Please give the another solution.......
Nilanka DharmadasaPosted Dec 23, 2009, 6:32 AM
did a small change in the code. Get this.
Nilanka DharmadasaPosted Dec 23, 2009, 6:22 AM
You are back.
Find my answer for your solution.
I have hardcoded the columns you need. If you want to change them you can do that by simply change that.
If you find this answer useful, please do not forget to tick 'Do you like this answer' checkbox.