关于xml使用的感悟
新建xml文件的情况可能不多,但对节点、属性的增删改查会很常见
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("data.xml"));
这两句应该很常用的,加载已经存在的xml文档。
XmlNode root;//根节点
root = xmldoc.DocumentElement;//获取根节点
这个用来获取xml的根节点
XmlNodeList nodeList = xmlDoc.SelectSingleNode("Employees").ChildNodes;//获取Employees节点的所有子节点
foreach (XmlNode xn in nodeList)//遍历所有子节点
{
XmlElement xe = (XmlElement)xn;//将子节点类型转换为XmlElement类型
if (xe.GetAttribute("genre") == "张三")//如果genre属性值为“张三”
{
xe.SetAttribute("genre", "update张三");//则修改该属性为“update张三”
XmlNodeList nls = xe.ChildNodes;//继续获取xe子节点的所有子节点
foreach (XmlNode xn1 in nls)//遍历
{
XmlElement xe2 = (XmlElement)xn1;//转换类型
if (xe2.Name == "author")//如果找到
{
&nb
相关文档:
import java.awt.Image;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class createXml
{
public static boolean writeXml(String path,String dir,String wpath,String wname)
{
File[] files = ReaderListFiles(path);
boo ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using i_salesDAL;
using i_s ......
XmlDocument xmldoc = new XmlDocument();//创建xml文档对象
XmlNode root;//根节点
xmldoc.Load(Server.MapPath("address.xml"));//加载xml文档
root = xmldoc.DocumentEle ......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white" viewSourceURL="srcview/index.html">
<mx:S ......