既然你已經解決了Load
/LoadXml
混亂,我想到的問題是命名空間;你有沒有例子xml?與命名空間處理XML得到......「有趣」 ;-p
例如:
XmlDocument doc = new XmlDocument();
doc.LoadXml(@"<test xmlns='myFunkyUri' value='abc'/>");
// wrong; no namespace consideration
XmlElement root = (XmlElement)doc.SelectSingleNode("test");
Console.WriteLine(root == null ? "(no root)" : root.GetAttribute("value"));
// right
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("x", "myFunkyUri"); // x is my alias for myFunkyUri
root = (XmlElement)doc.SelectSingleNode("x:test", nsmgr);
Console.WriteLine(root == null ? "(no root)" : root.GetAttribute("value"));
請注意,即使你的XML聲明XML別名,你可能仍然需要重新申報他們爲你命名-經理。
在這裏可能會出現多種錯誤,我懷疑這是文件擴展名。你有沒有看過調試器中的「doc」並確認它沒有加載? – womp 2009-07-23 04:02:39
您可以發佈其中一個XML文件的前幾行嗎? – 2009-07-23 08:46:41