xmldoc = new XmlDocument() ;
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration , "" , "" ) ;
xmldoc.AppendChild( xmlnode ) ;
xmlelem = xmldoc.CreateElement( "" , "root" , "" ) ;
xmldoc.AppendChild( xmlelem ) ;
xmlelem2 = xmldoc.CreateElement("img" ) ;
//想在这里给IMG加几个属性
xmldoc.ChildNodes.Item(1).AppendChild( xmlelem2 ) ;
xmldoc.Save( "c:\\data.xml" ) ; 我想让输出的样子是这个样子,要怎么写
<?xml version="1.0"?>
<root>
<img label="布达拉宫" id="72" picurl="2005-12-1\m33535143.jpg" picurl100="2005-12-1\m33535143.jpg" picurl500="2005-12-1\m33535143.jpg" picrar="0"/>
</root>
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration , "" , "" ) ;
xmldoc.AppendChild( xmlnode ) ;
xmlelem = xmldoc.CreateElement( "" , "root" , "" ) ;
xmldoc.AppendChild( xmlelem ) ;
xmlelem2 = xmldoc.CreateElement("img" ) ;
//想在这里给IMG加几个属性
xmldoc.ChildNodes.Item(1).AppendChild( xmlelem2 ) ;
xmldoc.Save( "c:\\data.xml" ) ; 我想让输出的样子是这个样子,要怎么写
<?xml version="1.0"?>
<root>
<img label="布达拉宫" id="72" picurl="2005-12-1\m33535143.jpg" picurl100="2005-12-1\m33535143.jpg" picurl500="2005-12-1\m33535143.jpg" picrar="0"/>
</root>
解决方案 »
- 100分求C#打印代码 明天加分 顶者有分
- datagridview表头的问题
- 想给程序设置一个老板键,大家帮忙出出注意!!越详细越好!!
- Remoting中的远程类是否必须要有默认无参构造函数?
- 请帮我看一下如何方便修改数据库的某个字段
- TextBox 屏蔽字符和汉字问题和复制粘贴问题
- 【100分求助】用WebRequest抓网页时,在碰到带汉字的url时,总是抓取的错误提示页面!??????
- 控件移动问题求助!
- 紧急求助,关于c#多线程的问题
- ashx文件中怎么调用外部类啊
- 问下在C#里面操作xml的一个问题
- 请教用Sqldataadapter.update(DataTable)插入一条记录后后怎么得到该datatable对应数据库表自增的字段值
XmlDeclaration xd = doc.CreateXmlDeclaration("1.0", "", "");
doc.AppendChild(xd);
XmlElement elem = doc.CreateElement("root");
doc.AppendChild(elem);
XmlElement e1 = doc.CreateElement("img");
e1.SetAttribute("label", "布达拉宫");
e1.SetAttribute("id", "72");
e1.SetAttribute("picurl",@"2005-12-1\m33535143.jpg");
e1.SetAttribute("picurl100",@"2005-12-1\m33535143.jpg");
e1.SetAttribute("picurl500",@"2005-12-1\m33535143.jpg");
e1.SetAttribute("picrar","0");
elem.AppendChild(e1);
doc.Save(@"..\..\newXml.xml");
xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration , "" , "" ) ;
xmldoc.AppendChild( xmlnode ) ;
xmlelem = xmldoc.CreateElement( "" , "root" , "" ) ;
xmldoc.AppendChild( xmlelem ) ;
xmlelem2 = xmldoc.CreateElement("img" ) ;
//想在这里给IMG加几个属性
xmlelem。setAttribute(。);
xmldoc.ChildNodes.Item(1).AppendChild( xmlelem2 ) ;
xmldoc.Save( "c:\\data.xml" ) ;
讲师: 邵志东
讲课时间: 2006年3月10日 10:00-11:30
产品: Visual Studio
技术: ASP.NET
技术等级: 200