本文介绍了使用c#拆分XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞!XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(@"D:\Prod.xml"); XmlNode node = xmlDoc.DocumentElement.FirstChild; XmlNodeList lstVideos = node.ChildNodes; for (int i = 0; i < lstVideos.Count; i++) { for (int j = 0; j < 3; j++) { Response.Write(" " + lstVideos[j].InnerText + " "); } Response.Write("<br>"); }xml file is: Collapse | Copy Code<?xml version="1.0"?>-<DocumentElement>-<test><c0>manas</c0><c1>100</c1><c2>20</c2><c3>33</c3><c4>54</c4> <c5>65</c5><c6>78</c6></test>So i wantlikemanas 100 20manas 33 54manas 65 78but coming likemanas 100 20manas 100 20manas 100 20manas 100 20manas 100 20Note:Column numbers are not fixed like 7.it may be 200, or 100.plz help me.推荐答案String firstItem = lstVideos[0].InnerText;for (int i = 1; i < lstVideos.Count; i+=2) { Response.Write(firstItem + " " + lstVideos[i].InnerText + " " + lstVideos[i+1] + " "); Response.Write("<br>"); } 这篇关于使用c#拆分XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 10:31