I have a xml file. this look like
<Worksheet ss:Name="Combined Account Statement">
-
<Table
ss:ExpandedColumnCount="15"
ss:ExpandedRowCount="96"
x:FullColumns="1"
x:FullRows="1"></Table></Workbook>I want to read the list of nodes from the xml file. I cant find the nodelist. Because of each xml tag have applied styles.
if
(xmlDoc.DocumentElement.SelectNodes("Workbook/Worksheet[ss:Name='Combined
Account Statement']").Count > 0)
MainNodeList =
xmlDoc.DocumentElement.SelectNodes("Workbook/Worksheet[ss:Name='Combined
Account Statement']");How can i read the list of nodes form xml files.
Kevin AungPosted Jan 5, 2011, 4:52 PM
say you have the following xml:
CODE:
using System;
using System.Xml.Linq;
using System.Xml.XPath;
namespace XmlApp
{
class Program
{
static void Main(string[] args)
{
string xmlPath = @"C:\temp\myXml.xml";
XDocument xDoc = XDocument.Load(xmlPath);
// This will select the root element and its descendants
XElement xElementRoot = xDoc.Element("root");
// Selects the child elements of "child1"
foreach (var e in xDoc.XPathSelectElement("root/child1").Descendants())
Console.WriteLine(e.Name + " - " + e.Value);
// Output:
// desc - Val1
// desc - Val2
}
}
}