Question : C# XML data showing System.Xml.XmlElement instead of the values

I have a C# application that reads in an XML file and build an array of objects which contain values from that XML file.  Unfortunately,  while it works in asp and in vb,  it is not returning the values in the click event.  The syntax of the xml should be "close" and I haven't a clue what is the holdup.  Below are the relevant pieces.

Please advise.

Thanks,
Howard

            XmlNodeList LoadNodeList (String sXMLFile, String sNodeSelector)
            {
                  XmlDocument objXML = new XmlDocument();
                  objXML.Load (sXMLFile);
                  return objXML.SelectNodes (sNodeSelector);                        
            }
            
            
            void AppInit()
            {
                  XmlNodeList objNodeList = null;
                  XmlNodeList objDataConnectionNodeList = null;
                  int nCnt, nCnt2;
                  
                  objNodeList = LoadNodeList (m_XMLFileName, "//Reconcile_DataSets/RecordSets/RecSet");
                  nCnt = objNodeList.Count;

                  cRec = new cReconciling[nCnt];
                  for (int nlp=0; nlp                  {
                        cRec[nlp]= new cReconciling();
                  }
                  
                  for (int nlp=0; nlp                  {
                        cRec[nlp].Name = objNodeList.Item(nlp).SelectSingleNode("Name").ToString();
                        cRec[nlp].Author = objNodeList.Item(nlp).SelectSingleNode("Author").ToString();
                        cRec[nlp].Description = objNodeList.Item(nlp).SelectSingleNode("Description").ToString();
                        cRec[nlp].theDate = objNodeList.Item(nlp).SelectSingleNode("Date").ToString();
                        
                        nCnt2 = objNodeList.Item(nlp).SelectNodes("DataConnection").Count;
                        cRec[nlp].SizeDataConnectionList (nCnt2);
                        objDataConnectionNodeList = objNodeList.Item(nlp).SelectNodes("DataConnection");
                        
                        
                        for (int nlp2=0; nlp2                        {
                              cRec[nlp].DataConnectionList(nlp2).ServerName = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("SERVER_NAME").ToString();
                              cRec[nlp].DataConnectionList(nlp2).DatabaseType = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("DATABASE_TYPE").ToString();
                              cRec[nlp].DataConnectionList(nlp2).DatabaseName = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("DATABASE_NAME").ToString();
                              cRec[nlp].DataConnectionList(nlp2).UID = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("UID").ToString();
                          cRec[nlp].DataConnectionList(nlp2).PWD = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("PWD").ToString();
                          cRec[nlp].DataConnectionList(nlp2).SQL_Header = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("SQL_HEADER").ToString();
                          cRec[nlp].DataConnectionList(nlp2).SQL = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("SQL").ToString();
                          cRec[nlp].DataConnectionList(nlp2).OutputFolder = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("OUTPUT_FOLDER").ToString();
                          cRec[nlp].DataConnectionList(nlp2).OutputFileName = objDataConnectionNodeList.Item(nlp2).SelectSingleNode("OUTPUT_FILENAME").ToString();                          
                        }                        
                  }
                  
            }
                  
            void cmdReadClick(object sender, System.EventArgs e)
            {            
                  String CRLF = Environment.NewLine;
                  String sHeader = "";
                  txtData.Text = txtData.Text + sHeader + CRLF;
                  
            int nRecs=2;            
           
            txtData.Text = "";
            for (int nlp=0; nlp            {
                  sHeader = "<<<" + "****************************************************" + ">>>" + CRLF;
                      txtData.Text = txtData.Text + sHeader + CRLF;
                      sHeader = "<<<" + "***************" + cRec[nlp].Name.ToString() + "***************" + ">>>";
                      txtData.Text = txtData.Text + sHeader + CRLF;
                  sHeader = "<<<" + "****************************************************" + ">>>" ;
                      txtData.Text = txtData.Text + sHeader + CRLF;
                      String sAccSQL = "", sAccHeader="";
                      for (int nlp2=0; nlp2ionCount; nlp2++)
                      {
                            sAccSQL = "SQL=" + cRec[nlp].DataConnectionList(nlp2).SQL.ToString() + CRLF;
                            sAccHeader = "SQL_HEADER=" + cRec[nlp].DataConnectionList(nlp2).SQL_Header.ToString() + CRLF;
                          txtData.Text = txtData.Text + sAccSQL + sAccHeader + CRLF + "**************************************************" + CRLF;
                      }
            }                  
            }      

Answer : C# XML data showing System.Xml.XmlElement instead of the values

My mistake - I'm used to working with XPath navigators. I think what you need is:
objNodeList.Item(nlp).SelectSingleNode("Name").InnerText
Random Solutions  
 
programming4us programming4us