using XPath

G

Guest

I can't seem to get the right node.

here is the code:
public Division(string FileName)
{
XmlDocument doc = new XmlDocument();
doc.Load(FileName);
XmlElement root = doc.DocumentElement;
rootstr = root.ToString();
XmlNode node = root.SelectSingleNode("//Settings//Current");
currentstr = node.ToString();

}

here is the xml file:
<?xml version="1.0" encoding="utf-8" ?><Settings><Current>Alpha</Current><Alpha><Divisor>786</Divisor><Quotient>4579</Quotient><Dividend>3599094</Dividend></Alpha><Beta><Divisor>867</Divisor><Quotient>5479</Quotient><Dividend>4750293</Dividend></Beta><Gamma><Divisor>793</Divisor><Quotient>6842</Quotient><Dividend>5425706</Dividend></Gamma></Settings>

both rootstr and currentstr are System.Xml.XmlElement

How do I get Alpha?

Thanks.
 
U

Uri Dor

you got the right node, just ToString() doesn't give its text -
InnerText does.

The debug command window is a wonderful thing (and so are watches)

have a nice one
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top