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
Code |
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

Amol Jadhav12 reputationPosted Jul 16, 2010, 1:20 AM EDT
Lakitha Munasinghe14 reputationPosted Jul 16, 2010, 2:16 AM EDT
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();
}
}
}
veena v3 reputationPosted Jul 21, 2010, 9:56 PM EDT
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