G
Guest
how do i select a single node value from the list?
ive tried with this, but it dosent work =/
private string FetchFieldFromXml(string strId)
{
string strText = "";
XmlNode fetchnode;
XmlDocument mydoc = new XmlDocument();
try
{
mydoc.Load(strXmlFieldPath);
fetchnode =
mydoc.SelectSingleNode("//fields//formmonthnames//monthnames[id=" + strId +
"]");
strText = fetchnode.InnerText;
}
catch (Exception e)
{
}
return strText;
}
xmlfile looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<fields>
<formmonthnames>
<monthnames id="01">January</monthnames>
<monthnames id="02">February</monthnames>
<monthnames id="03">March</monthnames>
<monthnames id="04">April</monthnames>
<monthnames id="05">May</monthnames>
<monthnames id="06">June</monthnames>
<monthnames id="07">July</monthnames>
<monthnames id="08">August</monthnames>
<monthnames id="09">September</monthnames>
<monthnames id="10">October</monthnames>
<monthnames id="11">November</monthnames>
<monthnames id="12">December</monthnames>
</formmonthnames>
</field>
ive tried with this, but it dosent work =/
private string FetchFieldFromXml(string strId)
{
string strText = "";
XmlNode fetchnode;
XmlDocument mydoc = new XmlDocument();
try
{
mydoc.Load(strXmlFieldPath);
fetchnode =
mydoc.SelectSingleNode("//fields//formmonthnames//monthnames[id=" + strId +
"]");
strText = fetchnode.InnerText;
}
catch (Exception e)
{
}
return strText;
}
xmlfile looks like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<fields>
<formmonthnames>
<monthnames id="01">January</monthnames>
<monthnames id="02">February</monthnames>
<monthnames id="03">March</monthnames>
<monthnames id="04">April</monthnames>
<monthnames id="05">May</monthnames>
<monthnames id="06">June</monthnames>
<monthnames id="07">July</monthnames>
<monthnames id="08">August</monthnames>
<monthnames id="09">September</monthnames>
<monthnames id="10">October</monthnames>
<monthnames id="11">November</monthnames>
<monthnames id="12">December</monthnames>
</formmonthnames>
</field>