当前位置:首页>科技>net程序的开发环境C.net
发布时间:2026-07-21阅读(1)
在前几介绍的XMl 操作时都是要求要求 实体类才能进行处理但有时要求必须对原XML文件进行解析以下是xml 序列化与反序列化的使用方法这次重点介绍一下如何对原生的XML文件进行常用的操作,现在小编就来说说关于net程序的开发环境?下面内容希望能帮助到你,我们来一起看看吧!

net程序的开发环境
在前几介绍的XMl 操作时都是要求要求 实体类才能进行处理。但有时要求必须对原XML文件进行解析。以下是xml 序列化与反序列化的使用方法。这次重点介绍一下如何对原生的XML文件进行常用的操作
c# .net XML 序列化与反序列化-NET FrameWork工具类分享
c# .net XML 工具类封装-NET FrameWork工具类分享
XmlDocument doc = new XmlDocument();doc.Load(@"fileName.xml");
doc.Save(@"fileName.xml");
XmlDocument doc = new XmlDocument();doc.LoadXml("<noteName></noteName>");
XmlNode xn = doc.SelectSingleNode("noteName"); //读取节点 string noteType = xn.GetAttribute("attrName").ToString(); //读取节点属性的值string value=xn.InnerText;//读取点中的属必值
XmlElement newElement = doc.createElement_x("noteName"); //创建新的节点//创建属性XmlAttribute xmlAttribute = doc.CreateAttribute("attrName");xmlAttribute.InnerText = "5";newElement.SetAttributeNode(xelType);//创建子节点 XmlElement xmlElement = doc.createElement_x("NodeName");xmlElement.InnerText = "Tang";newElement.AppendChild(xelAuthor);
XmlElement xmlElement = xmlDoc.DocumentElement; string partten = string.Format("/notes/notes[@Type=\"{0}\"]", "11");XmlElement xmlElementSelected = (XmlElement)xmlElement.SelectSingleNode(partten);这里的分析规则是XPath
上一篇:剧本杀怎么玩 剧本杀如何玩
下一篇:如何注册qq号 怎样注册qq号
Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图