Summary:
/// <Summary>
/// Create an XML document
/// </Summary>
/// <Param name = "name"> root node name </param>
/// <Param name = "type"> attribute value of a root node </param>
/// <Returns> </returns>
/// Moss call method: If you want to save the created file to the moss document library, then:
/// XmlDocument doc = XmlOperate. CreateXmlDocument ("project", "T ");
/// Add subnode methods, such as AddTaskNode (taskObj, ref doc );..
/// Byte [] fileContent = Encoding. UTF8.GetBytes (doc. OuterXml );
/// Folder. Files. Add ("name. xml", fileContent, true );
/// Web. Update ();
/// Method called in. net: Write to file, then:
/// Document = XmlOperate. CreateXmlDocument ("sex", "sexy ");
/// Document. Save ("c:/bookstore. xml ");
Public static XmlDocument CreateXmlDocument (string name, string type)
{
XmlDocument doc = null;
XmlElement rootEle = null;
Try
{
Doc = new XmlDocument ();
Doc. LoadXml ("<" + name + "/> ");
RootEle = doc. DocumentElement;
RootEle. SetAttribute ("type", type );
}
Catch (Exception er)
{
Throw er;
}
Return doc;
}
/// <Summary>
/// Add a child element under the root node