本文整理汇总了C#中System.Xml.XmlDocument.CreateNode方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.CreateNode方法的具体用法?C# System.Xml.XmlDocument.CreateNode怎么用?C# System.Xml.XmlDocument.CreateNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.CreateNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnPublishFolder_Click
private void btnPublishFolder_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtFolderPath.Text))
{
//To Publish Folder, add Data to XML
System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
// Load XML
objXmlDocument.Load(@".\Data\PublishedFolders.xml");
System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");
// Attribute Name
System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
objXmlAttribute.Value = "Carpeta";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Status
objXmlAttribute = objXmlDocument.CreateAttribute("Status");
objXmlAttribute.Value = "Enabled";
objXmlNode.Attributes.Append(objXmlAttribute);
// Attribute Path
objXmlAttribute = objXmlDocument.CreateAttribute("Path");
objXmlAttribute.Value = txtFolderPath.Text;
objXmlNode.Attributes.Append(objXmlAttribute);
// Add Node
objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
// Update File
objXmlDocument.Save(@".\Data\PublishedFolders.xml");
// Refresh List
LoadFolders();
}
}
示例2: GetFunctionsXml
/// <summary>
/// Returns an Xml document containing information on all of the functions in the TemplateGen
/// type from the current assembly
/// </summary>
/// <returns></returns>
public string GetFunctionsXml()
{
object obj = CurrentAssembly.CreateInstance(_ProjectNamespace + ".TemplateGen");
Type objType = obj.GetType();
MethodInfo[] methods = objType.GetMethods(BindingFlags.Public | BindingFlags.Static);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode rootNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "functions", "");
foreach (MethodInfo method in methods)
{
System.Xml.XmlNode functionNode = doc.CreateNode(System.Xml.XmlNodeType.Element, "function", "");
System.Xml.XmlAttribute attName = doc.CreateAttribute("name");
attName.Value = method.Name;
System.Xml.XmlAttribute attParamTypeName = doc.CreateAttribute("parametertypename");
ParameterInfo[] parameters = method.GetParameters();
switch (parameters.Length)
{
case 0:
attParamTypeName.Value = "";
break;
case 1:
attParamTypeName.Value = parameters[0].ParameterType.ToString();
break;
default:
attParamTypeName.Value = parameters[0].ParameterType.ToString();
// TODO: Determine how to handle Template vs. normal functions WRT number of parameters
//throw new Exception("Template functions can't have more than one parameter: "+ method.Name);
break;
}
functionNode.Attributes.Append(attName);
functionNode.Attributes.Append(attParamTypeName);
rootNode.AppendChild(functionNode);
}
doc.AppendChild(rootNode);
return doc.OuterXml;
}
示例3: SaveDB
public override void SaveDB(string filename, DataBase tDataBase)
{
//tDataBase.WriteXml(filename)
System.Xml.XmlDocument XMLDOC = new System.Xml.XmlDocument();
XMLDOC.LoadXml("<data></data>");
XmlAttribute attr;
XmlNode newTable;
XmlNode newRow;
XmlNode newColumn;
foreach (BlackLight.Services.DB.Table tTable in tDataBase)
{
newTable = XMLDOC.CreateNode(XmlNodeType.Element, "table", "");
XMLDOC.DocumentElement.AppendChild(newTable);
attr = XMLDOC.CreateAttribute("name");
attr.Value = tTable.Name;
newTable.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("columns");
attr.Value = Convert.ToString(tTable.Columns.Count);
newTable.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("primary");
attr.Value = tTable.PrimaryColumn;
newTable.Attributes.Append(attr);
foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
{
newColumn = XMLDOC.CreateNode(XmlNodeType.Element, "column", "");
newTable.AppendChild(newColumn);
attr = XMLDOC.CreateAttribute("name");
attr.Value = tColumn.Name;
newColumn.Attributes.Append(attr);
attr = XMLDOC.CreateAttribute("type");
attr.Value = Convert.ToString(tColumn.DType);
newColumn.Attributes.Append(attr);
}
foreach (BlackLight.Services.DB.Row tRow in tTable)
{
newRow = XMLDOC.CreateNode(XmlNodeType.Element, "row", "");
newTable.AppendChild(newRow);
foreach (BlackLight.Services.DB.Column tColumn in tTable.Columns)
{
attr = XMLDOC.CreateAttribute(tColumn.Name);
attr.Value = System.Convert.ToString(tRow[tColumn.Name]);
newRow.Attributes.Append(attr);
}
}
}
if (System.IO.Directory.Exists("data") == false)
{
System.IO.Directory.CreateDirectory("data");
}
XMLDOC.Save("data\\" + filename);
}