首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

有关System.Xml.XmlElement的有关问题

2011-12-29 
有关System.Xml.XmlElement的问题XmlDocumentdomnewXmlDocument()XmlDocumentnewdomnewXmlDocument()d

有关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     ,我如何才能查看到里面的元素节点呢   ?

[解决办法]

热点排行