C# and XML Document

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

I am having problems with the following code. I am able to open the xml
document and read it into memory and if I step through the code and look at
the variables, I can see that the XML document is correct. What is
happening is that what is being returned into TableName is
"System.Xml.XmlElement" If I look at the variables in the autos window, I
can see the following in InnerXML, <FOLDERNAME>Member</FOLDERNAME> etc.
Folders =
Doc.SelectSingleNode("SCHEMA").SelectSingleNode("FOLDER").SelectSingleNode("SUBFOLDERS").ChildNodes;

TableList = new ArrayList();

foreach(XmlNode Folder in Folders)

{

TableName = Folder.SelectSingleNode("FOLDERNAME").ToString();

TableList.Add(TableName);

}

return TableList;



Thanks

Bill
 
news.microsoft.com said:
I am having problems with the following code. I am able to open the xml
document and read it into memory and if I step through the code and look at
the variables, I can see that the XML document is correct. What is
happening is that what is being returned into TableName is
"System.Xml.XmlElement" If I look at the variables in the autos window, I
can see the following in InnerXML, <FOLDERNAME>Member</FOLDERNAME> etc.
Folders =
Doc.SelectSingleNode("SCHEMA").SelectSingleNode("FOLDER").SelectSingleNode("SUBFOLDERS").ChildNodes;

TableList = new ArrayList();

foreach(XmlNode Folder in Folders)

{

TableName = Folder.SelectSingleNode("FOLDERNAME").ToString();

TableList.Add(TableName);

}

return TableList;

You seem to be assuming that XmlNode.ToString will return the value of the
node. This is clearly not the case.

You want the InnerText property of the XmlNode.

John
 
Back
Top