using XPath

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Back
Top