====一个最简单的Net操作XML的程序,居然通不过,请各位帮忙看一下!!=====
alj 2005-03-20 11:57:54 程序如下:
private void btnXmlTest_Click(object sender, System.EventArgs e)
{
XmlDocument xmlDoc=new XmlDocument();
XmlNode ndRoot=xmlDoc.CreateNode(XmlNodeType.Element,"Book","");
SetNodeAttribute(ref ndRoot,"Name","sdfasfd asdf");
xmlDoc.DocumentElement.AppendChild(ndRoot);
tbInfo2.Text=xmlDoc.OuterXml;
}
private void SetNodeAttribute(ref System.Xml.XmlNode node,string attriName,string attriValue)
{
XmlDocument xDoc=new XmlDocument();
XmlAttribute tNode=xDoc.CreateAttribute(attriName);
tNode.Value=attriValue;
node.Attributes.Append(tNode);
}
我的目的就像想得到如下的XML文本:
<?xml version="1.0"?>
<Book Name="asdfasdf asd"/>
那里出错啦?