日期:2014-05-19  浏览次数:20875 次

高手帮忙解决一下C#读xml内容的问题?多谢
<?xml   version= "1.0 "   encoding= "GB2312 "   ?>  
-   <resultList   xmlns= "http://www.streaming21.com/4.5/server "   xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance "   xsi:schemaLocation= "http://www.streaming21.com/4.5/server   ../schema/S21XmlResult.xsd ">
-   <getDiskInfo_Result>
-   <diskInfo>
    <fileSystem> WFS </fileSystem>  
    <physicalName> D: </physicalName>  
    <volumeLabel   />  
    <description   />  
    <performanceNote   />  
    <systemNote> WinFS   Version   5.0 </systemNote>  
    <diskSizeInBytes> 63046737920 </diskSizeInBytes>  
    <usedSizeInBytes> 44039372800 </usedSizeInBytes>  
    </diskInfo>
    </getDiskInfo_Result>
    </resultList>

这是XML内容,我把这些信息读出来后如何才能获取physicalName的值.
以下是我操作的方式:

strResponse为一字符串,存上面的XML内容.

  XmlDocument   xd   =   new   XmlDocument();
                        xd.LoadXml(strResponse);
XmlNodeList   ServerNodeList   =   xd.SelectNodes( "/resultList/getDiskInfoList_Result/diskInfoList/diskInfo ");
                        //XmlNodeList   ServerNodeList   =   xd.SelectNodes( "resultList/getDiskInfoList_Result/diskInfoList/diskInfo ");
                        int   i   =   ServerNodeList.Count;
                        if   (ServerNodeList.Count.Equals(0))
                        {
                                MessageBox.Show( "ServerConfig       File       is       error       ,       please       reset       it ");
                                return;
                        }
                        int   serverInfoNum   =   1;
                        foreach   (XmlNode   ServerNode   in   ServerNodeList)
                        {
                                textBox1.Text   =   ServerNode.Attributes[0].InnerText;
                                //textBox2.Text   =   ServerNode.ChildNodes[0].InnerText;
                                //textBox3.tex