本文整理汇总了C#中System.Xml.XmlElement.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.AppendChild方法的具体用法?C# XmlElement.AppendChild怎么用?C# XmlElement.AppendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.AppendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCompositeIdGenerator
protected override void AddCompositeIdGenerator(XmlDocument xmldoc, XmlElement idElement, List<ColumnDetail> compositeKey, ApplicationPreferences applicationPreferences)
{
foreach (ColumnDetail column in compositeKey)
{
var keyElement = xmldoc.CreateElement("key-property");
string propertyName =
column.ColumnName.GetPreferenceFormattedText(applicationPreferences);
if (applicationPreferences.FieldGenerationConvention == FieldGenerationConvention.Property)
{
idElement.SetAttribute("name", propertyName.MakeFirstCharLowerCase());
}
else
{
if (applicationPreferences.FieldGenerationConvention == FieldGenerationConvention.AutoProperty)
{
propertyName = column.ColumnName.GetFormattedText();
}
keyElement.SetAttribute("name", propertyName);
}
var mapper = new DataTypeMapper();
Type mapFromDbType = mapper.MapFromDBType(column.DataType, column.DataLength,
column.DataPrecision,
column.DataScale);
keyElement.SetAttribute("type", mapFromDbType.Name);
keyElement.SetAttribute("column", column.ColumnName);
if (applicationPreferences.FieldGenerationConvention != FieldGenerationConvention.AutoProperty)
{
keyElement.SetAttribute("access", "field");
}
idElement.AppendChild(keyElement);
}
}
示例2: ModelFunctionParameter
internal ModelFunctionParameter(EDMXFile parentFile, ModelFunction storeFunction, string name, int ordinal, XmlElement parentTypeElement)
: base(parentFile)
{
_parentFunction = storeFunction;
_parameterElement = EDMXDocument.CreateElement("Parameter", NameSpaceURIcsdl);
if (ordinal > 0)
{
XmlNodeList propertyNodes = parentTypeElement.SelectNodes("edm:Parameter", NSM);
if (propertyNodes.Count >= ordinal)
{
parentTypeElement.InsertAfter(_parameterElement, propertyNodes[ordinal - 1]);
}
else
{
parentTypeElement.AppendChild(_parameterElement);
}
}
else
{
parentTypeElement.AppendChild(_parameterElement);
}
this.Name = name;
}
示例3: AddChildren
void AddChildren(XmlElement gapi_child)
{
foreach (XmlNode node in elem.ChildNodes) {
XmlElement child = node as XmlElement;
if (child == null)
continue;
switch (node.Name) {
case "constructor":
gapi_child.AppendChild (new Ctor (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
case "doc":
// Ignore
break;
case "field":
gapi_child.AppendChild (new Field (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
case "function":
case "method":
gapi_child.AppendChild (new Method (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
default:
Console.WriteLine ("Unexpected child on record element: " + node.Name);
break;
}
}
}
示例4: SetXML
internal override void SetXML(XmlElement xml, BaseClassIfc host, HashSet<int> processed)
{
base.SetXML(xml, host, processed);
xml.AppendChild(ContainerProfile.GetXML(xml.OwnerDocument, "ContainerProfile", this, processed));
xml.AppendChild(Operator.GetXML(xml.OwnerDocument, "Operator", this, processed));
setAttribute(xml, "Label", Label);
}
示例5: CreateLayoutNode
public int CreateLayoutNode(XmlDocument document, XmlElement parent, ILayout layout)
{
XmlElement element = null, components = null;
if (document != null)
{
element = document.CreateElement("Settings");
components = document.CreateElement("Components");
}
var hashCode = SettingsHelper.CreateSetting(document, parent, "Mode", layout.Mode)
^ SettingsHelper.CreateSetting(document, parent, "X", layout.X)
^ SettingsHelper.CreateSetting(document, parent, "Y", layout.Y)
^ SettingsHelper.CreateSetting(document, parent, "VerticalWidth", layout.VerticalWidth)
^ SettingsHelper.CreateSetting(document, parent, "VerticalHeight", layout.VerticalHeight) * 1000
^ SettingsHelper.CreateSetting(document, parent, "HorizontalWidth", layout.HorizontalWidth)
^ SettingsHelper.CreateSetting(document, parent, "HorizontalHeight", layout.HorizontalHeight) * 1000
^ ToElement(document, element, layout.Settings);
if (document != null)
{
parent.AppendChild(element);
parent.AppendChild(components);
}
var layoutComponents = new List<ILayoutComponent>(layout.LayoutComponents);
var count = 1;
foreach (var component in layoutComponents)
{
try
{
if (document != null)
{
var componentElement = document.CreateElement("Component");
components.AppendChild(componentElement);
SettingsHelper.CreateSetting(document, componentElement, "Path", component.Path);
var settings = document.CreateElement("Settings");
settings.InnerXml = component.Component.GetSettings(document).InnerXml;
componentElement.AppendChild(settings);
}
else
{
var type = component.Component.GetType();
if (type.GetMethod("GetSettingsHashCode") != null)
hashCode ^= ((dynamic)component.Component).GetSettingsHashCode() ^ component.GetHashCode() * count;
else
hashCode ^= component.Component.GetSettings(new XmlDocument()).InnerXml.GetHashCode() ^ component.GetHashCode() * count;
}
}
catch (Exception e)
{
Log.Error(e);
}
count++;
}
return hashCode;
}
示例6: SaveNode
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
Controller.SaveNode(xmlDoc, nodeElement, context);
var outEl = xmlDoc.CreateElement("Name");
outEl.SetAttribute("value", NickName);
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Description");
outEl.SetAttribute("value", Description);
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Inputs");
foreach (string input in InPortData.Select(x => x.NickName))
{
XmlElement inputEl = xmlDoc.CreateElement("Input");
inputEl.SetAttribute("value", input);
outEl.AppendChild(inputEl);
}
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Outputs");
foreach (string output in OutPortData.Select(x => x.NickName))
{
XmlElement outputEl = xmlDoc.CreateElement("Output");
outputEl.SetAttribute("value", output);
outEl.AppendChild(outputEl);
}
nodeElement.AppendChild(outEl);
}
示例7: StoreMemberProperty
internal StoreMemberProperty(EDMXFile parentFile, StoreEntityType storeEntityType, string name, int ordinal, XmlElement parentTypeElement)
: base(parentFile)
{
_parentEntityType = storeEntityType;
_parentEntityType.Removed += new EventHandler(ParentEntityType_Removed);
_propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIssdl);
if (ordinal > 0)
{
XmlNodeList propertyNodes = parentTypeElement.SelectNodes("ssdl:Property", NSM);
if (propertyNodes.Count >= ordinal)
{
parentTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]);
}
else
{
parentTypeElement.AppendChild(_propertyElement);
}
}
else
{
parentTypeElement.AppendChild(_propertyElement);
}
this.Name = name;
}
示例8: KeyValue2Xml
private static void KeyValue2Xml(XmlElement node, KeyValuePair<string, object> Source)
{
object kValue = Source.Value;
if (kValue.GetType() == typeof(Dictionary<string, object>))
{
foreach (KeyValuePair<string, object> item in kValue as Dictionary<string, object>)
{
XmlElement element = node.OwnerDocument.CreateElement(item.Key);
KeyValue2Xml(element, item);
node.AppendChild(element);
}
}
else if (kValue.GetType() == typeof(object[]))
{
object[] o = kValue as object[];
for (int i = 0; i < o.Length; i++)
{
XmlElement xitem = node.OwnerDocument.CreateElement("Item");
KeyValuePair<string, object> item = new KeyValuePair<string, object>("Item", o[i]);
KeyValue2Xml(xitem, item);
node.AppendChild(xitem);
}
}
else
{
XmlText text = node.OwnerDocument.CreateTextNode(kValue.ToString());
node.AppendChild(text);
}
}
示例9: AddChildren
void AddChildren(XmlElement gapi_child)
{
foreach (XmlNode node in elem.ChildNodes) {
XmlElement child = node as XmlElement;
if (child == null)
continue;
switch (node.Name) {
case "glib:signal":
gapi_child.AppendChild (new Signal (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
case "method":
gapi_child.AppendChild (new Method (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
case "prerequisite":
gapi_child.SetAttribute ("prerequisite", child.GetAttribute ("name"));
break;
case "property":
gapi_child.AppendChild (new Property (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
case "virtual-method":
gapi_child.AppendChild (new VirtualMethod (child).CreateGapiElement (gapi_child.OwnerDocument));
break;
default:
Console.WriteLine ("Unexpected child on interface element: " + node.Name);
break;
}
}
}
示例10: WriteXml
protected override void WriteXml(object entity, XmlElement parent, IFormatProvider formatProvider, string localName, bool mandatory)
{
object value = GetValue(entity);
if (_Adapter.IsEmpty(value))
{
if (mandatory)
{
XmlElement member = parent.OwnerDocument.CreateElement(localName);
parent.AppendChild(member);
string content = _Adapter.FormatObject(value, formatProvider);
if (!string.IsNullOrEmpty(content))
member.AppendChild(member.OwnerDocument.CreateCDataSection(content));
}
}
else
{
XmlElement member = parent.OwnerDocument.CreateElement(localName);
parent.AppendChild(member);
string content = _Adapter.FormatObject(value, formatProvider);
member.AppendChild(parent.OwnerDocument.CreateCDataSection(content));
}
}
示例11: WriteTo
public void WriteTo(XmlElement element)
{
//JobType
Debug.Assert(element.OwnerDocument != null, "element.OwnerDocument != null");
var jobTypeElement = element.OwnerDocument.CreateElement("JobType");
JobType.WriteTo(jobTypeElement);
element.AppendChild(jobTypeElement);
//JobParameters
Debug.Assert(element.OwnerDocument != null, "element.OwnerDocument != null");
var jobParametersElement = element.OwnerDocument.CreateElement("JobParameters");
if (JobParameters != null)
{
foreach (var jobParameter in JobParameters)
{
var jobParameterElement = element.OwnerDocument.CreateElement("JobParameter");
var jobParameterNameElement = element.OwnerDocument.CreateAttribute("Name");
jobParameterNameElement.Value = jobParameter.Key;
var jobParameterValueElement = element.OwnerDocument.CreateAttribute("Value");
jobParameterValueElement.Value = jobParameter.Value;
jobParameterElement.Attributes.Append(jobParameterNameElement);
jobParameterElement.Attributes.Append(jobParameterValueElement);
jobParametersElement.AppendChild(jobParameterElement);
}
element.AppendChild(jobParametersElement);
}
}
示例12: ModelMemberProperty
internal ModelMemberProperty(EDMXFile parentFile, ModelEntityType modelEntityType, string name, int ordinal, XmlElement entityTypeElement)
: base(parentFile)
{
_modelEntityType = modelEntityType;
_modelEntityType.Removed += new EventHandler(ModelEntityType_Removed);
_propertyElement = EDMXDocument.CreateElement("Property", NameSpaceURIcsdl);
if (ordinal > 0)
{
XmlNodeList propertyNodes = entityTypeElement.SelectNodes("edm:Property", NSM);
if (propertyNodes.Count >= ordinal)
{
entityTypeElement.InsertAfter(_propertyElement, propertyNodes[ordinal - 1]);
}
else
{
entityTypeElement.AppendChild(_propertyElement);
}
}
else
{
entityTypeElement.AppendChild(_propertyElement);
}
Name = name;
}
示例13: addToXml
static private int addToXml(string filePath, XmlElement root,int count)
{
DirectoryInfo di = new DirectoryInfo(filePath);
foreach (FileInfo file in di.GetFiles())
{
XmlElement xel = xmlDoc.CreateElement("FILE");//创建一个<file>节点
xel.SetAttribute("NAME", file.Name);//设置该节点genre属性
xel.SetAttribute("SIZE", file.Length.ToString());//设置该节点genre属性
xel.SetAttribute("CREATE_TIME", file.CreationTime.ToString());
xel.SetAttribute("MODIFY_TIME", file.LastWriteTime.ToString());
xel.SetAttribute("ATTRIBUTES", file.Attributes.ToString());
root.AppendChild(xel);
count=count+1;
}
foreach (DirectoryInfo directory in di.GetDirectories())
{
XmlElement xel = xmlDoc.CreateElement("DIRECTORY");//创建一个<directory>节点
xel.SetAttribute("NAME", directory.Name);//设置该节点ISBN属性
xel.SetAttribute("CREATE_TIME", directory.CreationTime.ToString());
xel.SetAttribute("MODIFY_TIME", directory.LastWriteTime.ToString());
xel.SetAttribute("ATTRIBUTES", directory.Attributes.ToString());
root.AppendChild(xel);
count= addToXml(filePath + @"\" + directory.Name, xel,count);
}
return count;
}
示例14: AddGeneralProperties
private static void AddGeneralProperties(IHeaders props, XmlElement item)
{
string prop;
var ownerDocument = item.OwnerDocument;
if (ownerDocument == null) {
throw new ArgumentNullException(nameof(item));
}
if (props.TryGetValue("DateO", out prop)) {
var e = ownerDocument.CreateElement("dc", "date", NS_DC);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Genre", out prop)) {
var e = ownerDocument.CreateElement("upnp", "genre", NS_UPNP);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Description", out prop)) {
var e = ownerDocument.CreateElement("dc", "description", NS_DC);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Artist", out prop)) {
var e = ownerDocument.CreateElement("upnp", "artist", NS_UPNP);
e.SetAttribute("role", "AlbumArtist");
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Performer", out prop)) {
var e = ownerDocument.CreateElement("upnp", "artist", NS_UPNP);
e.SetAttribute("role", "Performer");
e.InnerText = prop;
item.AppendChild(e);
e = ownerDocument.CreateElement("dc", "creator", NS_DC);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Album", out prop)) {
var e = ownerDocument.CreateElement("upnp", "album", NS_UPNP);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Track", out prop)) {
var e = ownerDocument.CreateElement(
"upnp", "originalTrackNumber", NS_UPNP);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Creator", out prop)) {
var e = ownerDocument.CreateElement("dc", "creator", NS_DC);
e.InnerText = prop;
item.AppendChild(e);
}
if (props.TryGetValue("Director", out prop)) {
var e = ownerDocument.CreateElement("upnp", "director", NS_UPNP);
e.InnerText = prop;
item.AppendChild(e);
}
}
示例15: AddCover
private void AddCover(IRequest request, IMediaResource resource,
XmlElement item)
{
var result = item.OwnerDocument;
var cover = resource as IMediaCover;
if (cover == null) {
return;
}
try {
var c = cover.Cover;
var curl = String.Format(
"http://{0}:{1}{2}cover/{3}/i.jpg",
request.LocalEndPoint.Address,
request.LocalEndPoint.Port,
prefix,
resource.Id
);
var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP);
var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA);
profile.InnerText = "JPEG_TN";
icon.SetAttributeNode(profile);
icon.InnerText = curl;
item.AppendChild(icon);
icon = result.CreateElement("upnp", "icon", NS_UPNP);
profile = result.CreateAttribute("dlna", "profileID", NS_DLNA);
profile.InnerText = "JPEG_TN";
icon.SetAttributeNode(profile);
icon.InnerText = curl;
item.AppendChild(icon);
var res = result.CreateElement(string.Empty, "res", NS_DIDL);
res.InnerText = curl;
res.SetAttribute("protocolInfo", string.Format(
"http-get:*:{1}:DLNA.ORG_PN={0};DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS={2}",
c.PN, DlnaMaps.Mime[c.Type], DlnaMaps.DefaultStreaming
));
var width = c.MetaWidth;
var height = c.MetaHeight;
if (width.HasValue && height.HasValue) {
res.SetAttribute("resolution", string.Format("{0}x{1}", width.Value, height.Value));
}
else {
res.SetAttribute("resolution", "200x200");
}
res.SetAttribute("protocolInfo", string.Format(
"http-get:*:image/jpeg:DLNA.ORG_PN=JPEG_TN;DLNA.ORG_OP=01;DLNA.ORG_CI=1;DLNA.ORG_FLAGS={0}",
DlnaMaps.DefaultInteractive
));
item.AppendChild(res);
}
catch (Exception) {
return;
}
}