本文整理汇总了C#中System.Xml.XmlDocument.CreateElement方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.CreateElement方法的具体用法?C# System.Xml.XmlDocument.CreateElement怎么用?C# System.Xml.XmlDocument.CreateElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.CreateElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getClaims
public System.Xml.XmlDocument getClaims()
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement claims = doc.CreateElement("claims");
foreach(TurfWarsGame.Claim c in TurfWars.Global.game.getClaims())
{
System.Xml.XmlElement claim = doc.CreateElement("claim");
System.Xml.XmlElement owners = doc.CreateElement("owners");
foreach (string u in c.getOwners().Keys)
{
System.Xml.XmlElement owner = doc.CreateElement("owner");
owner.SetAttribute("name", u);
owner.SetAttribute("share", c.getOwners()[u].ToString());
owners.AppendChild(owner);
}
System.Xml.XmlElement tile = doc.CreateElement("tile");
tile.SetAttribute("north",c.box.north.ToString());
tile.SetAttribute("south",c.box.south.ToString());
tile.SetAttribute("west", c.box.west.ToString());
tile.SetAttribute("east", c.box.east.ToString());
claim.AppendChild(owners);
claim.AppendChild(tile);
claims.AppendChild(claim);
}
doc.AppendChild(claims);
return doc;
}
示例2: GenerateDefinitionXmlElement
public System.Xml.XmlElement GenerateDefinitionXmlElement(EntitiesGenerator.Definitions.DataTable table)
{
System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
System.Xml.XmlElement definitionElement = xmlDocument.CreateElement("Definition");
System.Xml.XmlElement xmlElement = xmlDocument.CreateElement("DataTable");
System.Xml.XmlAttribute tableNameXmlAttribute = xmlDocument.CreateAttribute("TableName");
tableNameXmlAttribute.Value = table.TableName.Trim();
xmlElement.Attributes.Append(tableNameXmlAttribute);
System.Xml.XmlAttribute sourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
sourceNameXmlAttribute.Value = table.SourceName.Trim();
xmlElement.Attributes.Append(sourceNameXmlAttribute);
foreach (EntitiesGenerator.Definitions.DataColumn column in table.Columns)
{
System.Xml.XmlElement dataColumnXmlElement = xmlDocument.CreateElement("DataColumn");
System.Xml.XmlAttribute dataColumnColumnNameXmlAttribute = xmlDocument.CreateAttribute("ColumnName");
dataColumnColumnNameXmlAttribute.Value = column.ColumnName.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnColumnNameXmlAttribute);
System.Xml.XmlAttribute dataColumnSourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
dataColumnSourceNameXmlAttribute.Value = column.SourceName.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnSourceNameXmlAttribute);
System.Xml.XmlAttribute dataColumnDataTypeXmlAttribute = xmlDocument.CreateAttribute("DataType");
dataColumnDataTypeXmlAttribute.Value = column.DataType.Trim();
dataColumnXmlElement.Attributes.Append(dataColumnDataTypeXmlAttribute);
if (column.PrimaryKey)
{
System.Xml.XmlAttribute dataColumnPrimaryKeyXmlAttribute = xmlDocument.CreateAttribute("PrimaryKey");
dataColumnPrimaryKeyXmlAttribute.Value = column.PrimaryKey ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnPrimaryKeyXmlAttribute);
}
if (!column.AllowDBNull)
{
System.Xml.XmlAttribute dataColumnAllowDBNullXmlAttribute = xmlDocument.CreateAttribute("AllowDBNull");
dataColumnAllowDBNullXmlAttribute.Value = column.AllowDBNull ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnAllowDBNullXmlAttribute);
}
if (column.AutoIncrement)
{
System.Xml.XmlAttribute dataColumnAutoIncrementXmlAttribute = xmlDocument.CreateAttribute("AutoIncrement");
dataColumnAutoIncrementXmlAttribute.Value = column.AutoIncrement ? "true" : "false";
dataColumnXmlElement.Attributes.Append(dataColumnAutoIncrementXmlAttribute);
}
// TODO: caption.
xmlElement.AppendChild(dataColumnXmlElement);
}
definitionElement.AppendChild(xmlElement);
xmlDocument.AppendChild(definitionElement);
return xmlDocument.DocumentElement;
}
示例3: SetNode
private static void SetNode(string cpath)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(cpath);
Console.WriteLine("Adding to machine.config path: {0}", cpath);
foreach (DataProvider dp in dataproviders)
{
System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
if (node == null)
{
System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
node = doc.CreateElement("add");
System.Xml.XmlAttribute at = doc.CreateAttribute("name");
node.Attributes.Append(at);
at = doc.CreateAttribute("invariant");
node.Attributes.Append(at);
at = doc.CreateAttribute("description");
node.Attributes.Append(at);
at = doc.CreateAttribute("type");
node.Attributes.Append(at);
root.AppendChild(node);
}
node.Attributes["name"].Value = dp.name;
node.Attributes["invariant"].Value = dp.invariant;
node.Attributes["description"].Value = dp.description;
node.Attributes["type"].Value = dp.type;
Console.WriteLine("Added Data Provider node in machine.config.");
}
doc.Save(cpath);
Console.WriteLine("machine.config saved: {0}", cpath);
}
示例4: CreateXmlElement
// TODO: This is not really an extension, more a helper and so should be moved...
public static System.Xml.XmlElement CreateXmlElement( string tag, string content )
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlElement element = doc.CreateElement(tag);
doc.AppendChild(element);
element.AppendChild(doc.CreateTextNode(content));
return doc.DocumentElement;
}
示例5: Serialize
/// <include file='doc\IFormatter.uex' path='docs/doc[@for="IFormatter.Serialize"]/*' />
public void Serialize(Stream serializationStream, Object graph)
{
AccuDataObjectFormatter = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration Declaration = AccuDataObjectFormatter.CreateXmlDeclaration("1.0", "", "");
System.Xml.XmlElement Element = AccuDataObjectFormatter.CreateElement("NewDataSet");
if (graph != null)
{
if (graph.GetType().Equals(typeof(System.String)))
{
Element.InnerText = graph.ToString();
}
else if (graph.GetType().GetInterface("IEnumerable") != null)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsArray)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsClass)
{
Serialize(Element, graph);
}
else if (graph.GetType().IsPrimitive)
{
Element.InnerText = graph.ToString();
}
else if (graph.GetType().IsValueType)
{
System.Xml.XmlElement ValueType = AccuDataObjectFormatter.CreateElement(graph.GetType().Name);
Element.AppendChild(ValueType);
}
}
AccuDataObjectFormatter.AppendChild(Declaration);
AccuDataObjectFormatter.AppendChild(Element);
System.IO.StreamWriter writer = new StreamWriter(serializationStream);
writer.Write(AccuDataObjectFormatter.OuterXml);
writer.Flush();
writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
}
示例6: Xml
public Xml(string rootName)
{
_xml = new System.Xml.XmlDocument();
System.Xml.XmlDeclaration dec = _xml.CreateXmlDeclaration("1.0", null, null);
_xml.AppendChild(dec);
_root = _xml.CreateElement(rootName);
_xml.AppendChild(_root);
}
示例7: XmlUnescape
public static string XmlUnescape(string escaped)
{
string strReturnValue = null;
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode node = doc.CreateElement("root");
node.InnerXml = escaped;
strReturnValue = node.InnerText;
node = null;
doc = null;
return strReturnValue;
}
示例8: ToDocumentXmlText
public string ToDocumentXmlText()
{
System.Xml.XmlDocument datagram = new System.Xml.XmlDocument();
System.Xml.XmlNode b1 = datagram.CreateElement(_Datagram.ToUpper());
foreach (KeyValuePair<string, string> curr in Parameters)
{
System.Xml.XmlAttribute b2 = datagram.CreateAttribute(curr.Key);
b2.Value = curr.Value;
b1.Attributes.Append(b2);
}
b1.InnerText = this._InnerText;
datagram.AppendChild(b1);
return datagram.InnerXml;
}
示例9: getUserStats
public System.Xml.XmlDocument getUserStats(string user)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
TurfWarsGame.User u = TurfWars.Global.game.getUser(user);
System.Xml.XmlElement xmlUser = doc.CreateElement("user");
xmlUser.SetAttribute("name", user);
xmlUser.SetAttribute("balance", u.getAccountBalance().ToString());
xmlUser.SetAttribute("shares", u.shares.ToString());
doc.AppendChild(xmlUser);
return doc;
}
示例10: addClaim
public System.Xml.XmlDocument addClaim(string user, double lat, double lon)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
Geo.Box box = TurfWars.Global.game.addClaim(user, lat, lon);
System.Xml.XmlElement tile = doc.CreateElement("tile");
tile.SetAttribute("north", box.north.ToString());
tile.SetAttribute("south", box.south.ToString());
tile.SetAttribute("west", box.west.ToString());
tile.SetAttribute("east", box.east.ToString());
doc.AppendChild(tile);
return doc;
}
示例11: GetKML
/// <summary>
/// Get the kml for this list of datasets
/// </summary>
/// <param name="strWmsUrl"></param>
/// <param name="oDatasets"></param>
/// <param name="oSelectedDatasets"></param>
/// <returns></returns>
public static System.Xml.XmlDocument GetKML(string strWmsUrl, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
{
System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();
oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));
System.Xml.XmlElement oKml = oOutputXml.CreateElement("kml", "http://earth.google.com/kml/2.1");
oOutputXml.AppendChild(oKml);
System.Xml.XmlElement oDocument = oOutputXml.CreateElement("Document", "http://earth.google.com/kml/2.1");
System.Xml.XmlAttribute oAttr = oOutputXml.CreateAttribute("id");
oAttr.Value = "Geosoft";
oDocument.Attributes.Append(oAttr);
oKml.AppendChild(oDocument);
System.Xml.XmlElement oName = oOutputXml.CreateElement("name", "http://earth.google.com/kml/2.1");
oName.InnerText = "Geosoft Catalog";
oDocument.AppendChild(oName);
System.Xml.XmlElement oVisibility = oOutputXml.CreateElement("visibility", "http://earth.google.com/kml/2.1");
oVisibility.InnerText = "1";
oDocument.AppendChild(oVisibility);
System.Xml.XmlElement oOpen = oOutputXml.CreateElement("open", "http://earth.google.com/kml/2.1");
oOpen.InnerText = "1";
oDocument.AppendChild(oOpen);
foreach (string strKey in oSelectedDatasets)
{
Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];
if (oDataset != null)
OutputDataset(strWmsUrl, oDocument, oDataset);
}
return oOutputXml;
}
示例12: encodeDocument
/// <summary> <p>Creates an XML Document that corresponds to the given Message object. </p>
/// <p>If you are implementing this method, you should create an XML Document, and insert XML Elements
/// into it that correspond to the groups and segments that belong to the message type that your subclass
/// of XMLParser supports. Then, for each segment in the message, call the method
/// <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for
/// that segment and the corresponding Segment object from the given Message.</p>
/// </summary>
public override System.Xml.XmlDocument encodeDocument(Message source)
{
System.String messageClassName = source.GetType().FullName;
System.String messageName = messageClassName.Substring(messageClassName.LastIndexOf('.') + 1);
System.Xml.XmlDocument doc = null;
try
{
doc = new System.Xml.XmlDocument();
System.Xml.XmlElement root = doc.CreateElement(messageName);
doc.AppendChild(root);
}
catch (System.Exception e)
{
throw new NuGenHL7Exception("Can't create XML document - " + e.GetType().FullName, NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e);
}
encode(source, (System.Xml.XmlElement) doc.DocumentElement);
return doc;
}
示例13: BtnAdd_Click
private void BtnAdd_Click(object sender, System.EventArgs e)
{
if (doc == null)
{
doc = Framework.Class.XmlTool.GetInstance();
System.Xml.XmlNode project = doc.CreateElement("PROJECT");
doc.AppendChild(project);
Framework.Interface.Project.FrmProjectInfo win = new Framework.Interface.Project.FrmProjectInfo();
win.ShowDialog();
//doc.Save("aaa.xml");
RefreshChapterTree();
}
else
{
DevComponents.DotNetBar.MessageBoxEx.Show("不允许重复创建工程!", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
}
}
示例14: GetXml
/// <summary>
/// Get the xml for this list of datasets
/// </summary>\
/// <param name="oDapCommand"></param>
/// <param name="oDatasets"></param>
/// <param name="oSelectedDatasets"></param>
/// <returns></returns>
public static System.Xml.XmlDocument GetXml(Command oDapCommand, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
{
System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();
oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));
System.Xml.XmlElement oGeosoftXml = oOutputXml.CreateElement("geosoft_xml");
oOutputXml.AppendChild(oGeosoftXml);
foreach (string strKey in oSelectedDatasets)
{
Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];
if (oDataset != null)
OutputDataset(oDapCommand, oGeosoftXml, oDataset);
}
return oOutputXml;
}
示例15: SetValue
/// <summary>
/// 根据Key修改Value
/// </summary>
/// <param name="key">要修改的Key</param>
/// <param name="value">要修改为的值</param>
public static void SetValue(string key, string value)
{
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
System.Xml.XmlNode xNode;
System.Xml.XmlElement xElem1;
System.Xml.XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
if (xElem1 != null) xElem1.SetAttribute("value", value);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", key);
xElem2.SetAttribute("value", value);
xNode.AppendChild(xElem2);
}
xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
}