这是查询
XDocument application = XDocument.Load(@".\..\..\XmlFile\" + xmlFileName);
var elements = from p in application.Descendants("Function")
where ((string)p.Attribute("Fnumber").Value.Trim() == (SourceCodeParser.fCount.ToString().Trim()) && (string)p.Attribute("MethodName").Value.Trim() == (methodName) && (string) p.Parent.Parent.Attribute("ClassName").Value.Trim()== (className))
select p.Element("MethodDependencies");
以下是执行引发异常
的查询的代码段foreach (var file in elements)
{
file.Add(
new XElement("MethodDependency",
new XAttribute("MethodName", MethodName),
new XAttribute("ObjectName", ObjectName),
new XAttribute("CallNumber", SourceCodeParser.methodcallCount.ToString().Trim()),
new XElement("Arguments")
));
}
这是Xml结构
<Classes>
<Class ClassName="" ClassPath="" ModifiedDate="" CreationDate="" InheritedFrom="" Modifier="" Specifier="">
<Functions>
<Function ReturnType="" Fnumber="" AccessModifier="" AccessSpecifier="" MethodName="">
<Dependencies />
<MethodDependencies />
</Function>
</Functions>
</Class>
</Classes>
此查询适用于其他文件但在某些文件上引发异常,尽管所有文件的代码都相同...
有什么建议吗?