问题描述
我新学c#,老师给了5个xml文件,让我编个window程序读出里面的相关信息,并能在程序界面中进行修改,修改完还能再保存回xml第一个文件,ApplicationClientOptions.xml?xmlversion="1.0"?><Options><IsAutoLogin>False</IsAutoLogin><IsSaveUserInfomation>True</IsSaveUserInfomation><UserID>youbing</UserID><UserPassword></UserPassword><SkinName>Office2007Black</SkinName><IsStatusBarVisible>True</IsStatusBarVisible><IsToolBarVisible>True</IsToolBarVisible><IsUseTabbed>True</IsUseTabbed><RemoteServerList><RemoteServer>Base_Service.xml</RemoteServer><RemoteServer>Edcp_Service.xml</RemoteServer></RemoteServerList></Options>第2个<?xmlversion="1.0"?><AutoUpdateConfig><ServerAddress>http://192.168.60.5:6235</ServerAddress></AutoUpdateConfig>第3个</object><objectid="BaseRemoteServiceConfig"type="Eep.Framework.ClientUtils.RemoteServiceConfig,Eep.Framework.ClientUtils"init-method="Initialize"><propertyname="Name"value="基础应用远程服务"/><propertyname="Description"value="这个服务主要提供应用基本的服务"/><propertyname="ConfigFileName"value="BaseRemoteService.xml"/><propertyname="RemoteServiceProtocol"value="http"/><propertyname="RemoteServiceAddress"value="192.168.60.8"/><propertyname="RemoteServicePort"value="7250"/></object></objects>第4个<objectid="EdcpRemoteServiceConfig"type="Eep.Framework.ClientUtils.RemoteServiceConfig,Eep.Framework.ClientUtils"init-method="Initialize"><propertyname="Name"value="协同平台远程服务"/><propertyname="Description"value="这个服务主要提供协同平台的远程数据服务"/><propertyname="ConfigFileName"value="EdcpRemoteService.xml"/><propertyname="RemoteServiceProtocol"value="http"/><propertyname="RemoteServiceAddress"value="192.168.1.5"/><propertyname="RemoteServicePort"value="3562"/></object>第5个,<?xmlversion="1.0"?><configuration><configSections><sectionGroupname="spring"><sectionname="context"type="Spring.Context.Support.ContextHandler,Spring.Core"/><sectionname="objects"type="Spring.Context.Support.DefaultSectionHandler,Spring.Core"/><sectionname="parsers"type="Spring.Context.Support.ConfigParsersSectionHandler,Spring.Core"/></sectionGroup></configSections><system.runtime.remoting><application><channels><channelref="http"><clientProviders><formatterref="binary"/><providertype="Eep.Framework.ExtendUtils.Remoting.AuthenticationClientSinkProvider,Eep.Framework.ExtendUtils"customSinkType="Eep.Framework.ExtendUtils.Remoting.AuthenticationClientSink,Eep.Framework.ExtendUtils"/></clientProviders></channel></channels></application></system.runtime.remoting></configuration>我本来想创建个程序应用窗口,直接读进来,然后修改后再写回去,,结果读的进来,不知道怎么写回去,不知道怎么创建一个对象把xml文档读到一个xmldocument对象里,以后让程序窗口的读取这个对象操作,大家能帮这个忙么?谢谢,在线等
解决方案
解决方案二:
在第一个文件中程序选择好远程服务类型,底下的相关信息要随之变化,就是3,4,文件里的相关信息,,这个怎么解决也请帮助,
解决方案三:
您可以引一个usingSystem.Xml;其中:XmlDocumentdoc=newXmlDocument();doc.Load("xml的文件名");XmlNodenode=doc.SelectSingleNode("//节点的名称");....这是查找指定的某个节点,还有很多内容,你可以上msdn上找一下,很全的.
解决方案四:
我能读进来,,关键是现在我不会创建一个对象,,把xml文档读到一个xmldocument对象里,然后的读取对这个对象操作,这我不会,而且像这个<propertyname="Description"value="这个服务主要提供协同平台的远程数据服务"/>,我怎么提前中间的文字,
解决方案五:
if(File.Exists(filePath)){List<SystemPatches>tempList=newList<SystemPatches>();XmlSerializermySerializer=newXmlSerializer(typeof(List<SystemPatches>));using(FileStreammyFileStream=newFileStream(filePath,FileMode.Open)){tempList=(List<SystemPatches>)mySerializer.Deserialize(myFileStream);}systemPatchesList.AddRange(tempList);}XmlSerializerxmlSerializer=newXmlSerializer(typeof(List<SystemPatches>));using(StreamWritermyWriter=newStreamWriter(filePath)){xmlSerializer.Serialize(myWriter,systemPatchesList);}序列化和反序列化XML