日期:2014-05-19  浏览次数:20389 次

有关System.Xml.XmlElement的问题
XmlDocument   dom   =   new   XmlDocument();
XmlDocument   newdom   =   new   XmlDocument();
dom.LoadXml(usersxml);
XmlNodeList   orgList =   dom.SelectSingleNode( "organization ").ChildNodes;
XmlElement   newroot   =   newdom.CreateElement( "tree ");
newroot.SetAttribute( "text ", "root ");
foreach(XmlNode   xnode   in   orgList)
{
XmlElement   xe=(XmlElement)xnode;
string   str   =   xe.GetAttribute( "upid ")==null? " ":xe.GetAttribute( "upid ");
if(str== "0 "||str== "-1 "||str== " ")  
{
XmlElement   neworg   =   newdom.CreateElement( "tree ");
neworg.SetAttribute( "id ",xe.GetAttribute( "id "));
neworg.SetAttribute( "text ",xe.GetAttribute( "name "));
neworg.SetAttribute( "target ", " ");
neworg.SetAttribute( "action ", " ");
neworg   =   buileXmlTree(neworg,orgList,newdom);
newroot.AppendChild(neworg);
}
}
StreamWriter   sw   =   File.CreateText( "d:/1.txt ");
sw.Write(newroot);
sw.Close();

=========================
文本文件   写进去的   是   System.Xml.XmlElement     ,我如何才能查看到里面的元素节点呢   ?

------解决方案--------------------