if(telephone[0].ChildNodes[0].ChildNodes[0].InnerText != null)
    textBox1.Text=telephone[0].ChildNodes[0].ChildNodes[0].InnerText; 
else
    textBox1.Text = "";
//!!!!!!!!!!!!!!!!!!!!!!这里出了问题!!!

解决方案 »

  1.   

    最好先检测一下你的telephone是否为空?
      

  2.   

    对每一层都判断
    if(telephone.ChildNodes.Count > 0 && telephone[0].ChildNodes.Count > 0 && telephone[0].ChildNodes[0].ChildNodes.Count >0)
        textBox1.Text=telephone[0].ChildNodes[0].ChildNodes[0].InnerText; 
    else
        textBox1.Text = "";
      

  3.   

    为什么不论我写成
    XmlNodeList telephone=doc.GetElementsByTagName("预定书籍列表");
    还是
    XmlNodeList telephone=doc.GetElementsByTagName("预定书籍");
    telephone.Count都是0
    这个节点那里去了
    MY GOD