Hi,
Using LINQ to XML how to read XML node names??
I have the Following XML
Using LINQ to XML how to read XML node names??
I have the Following XML
|
I want to get all the node names inside .
i.e.
1)number
2)Cost
3)Order
4)article etc..
How to get the node name list?
thank you,
Veena
i.e.
1)number
2)Cost
3)Order
4)article etc..
How to get the node name list?
thank you,
Veena
veena vPosted Jul 22, 2010, 1:56 AM
Found solution for this
Now is there any way to read it in following order
1. Number
2. Cost
3. Cost.Code
4. Cost.Type etc..
Regards,
Veena
Lakitha MunasinghePosted Jul 16, 2010, 6:16 AM
XmlNodeList nodes = xmlNode.ChildNodes;
if (nodes[0].ChildNodes[0].ChildNodes[0].Name.Equals(OrderDocumentRow))
{
if (nodes[0].ChildNodes[0].ChildNodes[0].HasChildNodes)
{
XmlNodeList orderDocumentRowChilds= (nodes[0].ChildNodes[0].ChildNodes[0].ChildNodes;
}
}
If you want to get the values of each...
if (nodes[0].ChildNodes[0].ChildNodes[0].Name.Equals(OrderDocumentRow))
{
if (nodes[0].ChildNodes[0].ChildNodes[0].HasChildNodes)
{
for(int =0; i < nodes[0].ChildNodes[0].ChildNodes[0].ChildNodes.Count; i++)
{
string value = (nodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[i].InnerText.ToString();
}
}
}
Amol JadhavPosted Jul 16, 2010, 5:20 AM