本文整理汇总了C#中System.Xml.XmlDocument.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.AppendChild方法的具体用法?C# System.Xml.XmlDocument.AppendChild怎么用?C# System.Xml.XmlDocument.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.AppendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例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: 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;
}
示例6: 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);
}
示例7: 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;
}
示例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: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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);
}
}
示例13: CreateDocument
public static Asn1OutXml2 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new Asn1OutXml2(doc);
}
示例14: CreatePlist
private void CreatePlist()
{
var doc = new System.Xml.XmlDocument();
// don't resolve any URLs, or if there is no internet, the process will pause for some time
doc.XmlResolver = null;
{
var type = doc.CreateDocumentType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
doc.AppendChild(type);
}
var plistEl = doc.CreateElement("plist");
{
var versionAttr = doc.CreateAttribute("version");
versionAttr.Value = "1.0";
plistEl.Attributes.Append(versionAttr);
}
var dictEl = doc.CreateElement("dict");
plistEl.AppendChild(dictEl);
doc.AppendChild(plistEl);
#if true
// TODO: this seems to be the only way to get the target settings working
CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "UseTargetSettings");
#else
// build and intermediate file locations
CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "CustomLocation");
CreateKeyValuePair(doc, dictEl, "CustomBuildIntermediatesPath", "XcodeIntermediates"); // where xxx.build folders are stored
CreateKeyValuePair(doc, dictEl, "CustomBuildLocationType", "RelativeToWorkspace");
CreateKeyValuePair(doc, dictEl, "CustomBuildProductsPath", "."); // has to be the workspace folder, in order to write files to expected locations
// derived data
CreateKeyValuePair(doc, dictEl, "DerivedDataCustomLocation", "XcodeDerivedData");
CreateKeyValuePair(doc, dictEl, "DerivedDataLocationStyle", "WorkspaceRelativePath");
#endif
this.Document = doc;
}
示例15: CreateDocument
public static ResidualsDataSet22 CreateDocument(string encoding)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
return new ResidualsDataSet22(doc);
}