如果有任何错误,请从错误节点输出内容。 非常感谢任何有助于我的教程的帮助或指示。From the above XML I'd like to extract the following information:Transaction Date: 2013-10-11T13:37:47.3189748+01:00Compressed File Name: C:\inetpub\AllstateCTSNGCFI\AllstateCTSNGCFI.gzTransaction Success: trueTransaction Errors: No Errors Decompressed Files(<filetocompress>):CoverageUpdate.aspxCustomError.aspxExpandedCoverage.aspxGlobal.asaxbin\Allstate.CTS.SCDBPC.ProductCatalog.SCs.dlletc AnAnd if there are any errors, output the contents from the Error node.Any help or pointers to tutorials that will help me would be greatly appreciated.推荐答案 您可以使用XML序列化和反序列化。 请参阅以下链接,了解如何使用XML序列化和反序列化。 XML序列化和反序列化:第1部分 [ ^ ] You can use XML Serialization and Deserialization. See below link to see how to use XML Serialization and Deserialization. XML Serialization and Deserialization: Part-1[^] 添加注释的代码中的错误表明问题出在 xmlIDS.Substring() xmlIDS.IndexOf(Environment.NewLine)失败,因此返回-1,这是无效的 startIndex 参数值。 你确定表示换行符的表示在 xmlIDS 字符串中与相同Environment.NewLine ? 你是吗? 确定在 xmlIDS 中实际上 IS 换行?The error in your comment-added code indicates that the problem is with xmlIDS.Substring()The xmlIDS.IndexOf(Environment.NewLine) failed, so it returned -1 which is an invalid startIndex parameter value for Substring.Are you sure that the representation of the newline in the xmlIDS string is the same as Environment.NewLine?And, are you sure that there actually IS a newline in xmlIDS? 这篇关于帮助解析XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-11 05:02