Hey All,
There are many ways to skin a dog (I like cats so no cats) in .Net
I have an XML string in the following format (without linefeeds):
<remoteDir>
<dir>MyDir</dir>
<dir>MyDir2</dir>
<file>
<name>tst2_33520902.txt</name>
<size>11277</size>
<lastModTime m=\"10\" d=\"30\" y=\"2006\" hh=\"10\" mm=\"29\"
ss=\"0\" />
</file>
<file>
<name>tst3_36432046.txt</name>
<size>10897</size>
<lastModTime m=\"10\" d=\"30\" y=\"2006\" hh=\"7\" mm=\"51\"
ss=\"0\" />
</file>
</remoteDir>
i would like to get a list of directories and a list of the files and
attributes.
I have come up with the following. Is there a better way?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(sFileList);
XmlNodeList filelst = xmlDoc.GetElementsByTagName("file");
for (int i = 0; i < filelst.Count; i++)
{
XmlElement afile = (XmlElement) filelst[i];
XmlElement afilename =
(XmlElement)afile.GetElementsByTagName("name")[0];
XmlElement afilesize =
(XmlElement)afile.GetElementsByTagName("size")[0];
System.Console.WriteLine(afilename.FirstChild.Valu e + " " +
afilesize.FirstChild.Value);
}
I would do the same thing to get the list of directories.
Thoughts?
Thanks much!
~Gina~