本文整理汇总了C#中System.Xml.XmlNode.CloneNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.CloneNode方法的具体用法?C# XmlNode.CloneNode怎么用?C# XmlNode.CloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.CloneNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadStyle
/// <summary>
/// read the styles of the chart
/// </summary>
/// <param name="node"></param>
/// <param name="styleType"></param>
/// <returns></returns>
public IStyle ReadStyle(XmlNode node,string styleType)
{
switch(styleType)
{
case "chart":
return CreateChartStyle(node.CloneNode (true));
case "title":
return CreateChartTitleStyle(node.CloneNode (true));
case "legend":
return CreateChartLegendStyle(node.CloneNode (true));
case"plotarea":
return CreateChartPlotAreaStyle(node.CloneNode (true));
case"axes":
return CreateChartAxesStyle(node.CloneNode (true));
case"series":
return CreateChartSeriesStyle(node.CloneNode (true));
case"wall":
return CreateChartWallStyle(node.CloneNode (true));
case"floor":
return CreateChartFloorStyle(node.CloneNode (true));
case "dr3d":
//return CreateChartDr3dLightStyle(node.CloneNode (true));
default:
return null;
}
}
示例2: CreateTextObject
/// <summary>
/// Creates the text object.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="aTextNode">A text node.</param>
/// <returns></returns>
public IText CreateTextObject(IDocument document, XmlNode aTextNode)
{
//aTextNode.InnerText = this.ReplaceSpecialCharacter(aTextNode.InnerText);
int i=0;
if (aTextNode.OuterXml.IndexOf("Contains state ") > -1)
i++;
switch(aTextNode.Name)
{
case "#text":
return new SimpleText(document, aTextNode.InnerText);
case "text:span":
return CreateFormatedText(document, aTextNode);
case "text:bookmark":
return CreateBookmark(document, aTextNode , BookmarkType.Standard);
case "text:bookmark-start":
return CreateBookmark(document, aTextNode , BookmarkType.Start);
case "text:bookmark-end":
return CreateBookmark(document, aTextNode , BookmarkType.End);
case "text:a":
return CreateXLink(document, aTextNode);
case "text:note":
return CreateFootnote(document, aTextNode);
case "text:line-break":
return new LineBreak(document);
case "text:s":
return new WhiteSpace(document, aTextNode.CloneNode(true));
case "text:tab":
return new TabStop(document);
default:
return null;
}
}
示例3: HTMLDefinitionNode
public HTMLDefinitionNode(XmlNode node, HTMLParserContext context)
{
m_sourceNode = node.CloneNode(true);
m_name = node.Name;
m_subNodes = new ArrayList();
m_attributes = new Dictionary<string, AttributeProperties>();
//Instead of dealing with xml nodes themselves its going to be easier to just deconstruct the whole thing, and recreate XML nodes in the final document
decodeSourceNode(node, context);
}
示例4: CreateUnknownStyle
/// <summary>
/// Creates the unknown style.
/// </summary>
/// <param name="styleNode">The style node.</param>
private void CreateUnknownStyle(XmlNode styleNode)
{
if (!this._common)
this._document.Styles.Add(new UnknownStyle(this._document, styleNode.CloneNode(true)));
else
this._document.CommonStyles.Add(new UnknownStyle(this._document, styleNode.CloneNode(true)));
}
示例5: SortNodes
/// <summary>
/// Sorts the documents.
/// </summary>
/// <param name="parentNode">The parent node.</param>
public static void SortNodes(ref XmlNode parentNode)
{
XmlNode n = parentNode.CloneNode(true);
// remove all children from original node
string xpath = UmbracoSettings.UseLegacyXmlSchema ? "./node" : "./* [@id]";
foreach (XmlNode child in parentNode.SelectNodes(xpath))
parentNode.RemoveChild(child);
XPathNavigator nav = n.CreateNavigator();
XPathExpression expr = nav.Compile(xpath);
expr.AddSort("@sortOrder", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
XPathNodeIterator iterator = nav.Select(expr);
while (iterator.MoveNext())
parentNode.AppendChild(
((IHasXmlNode)iterator.Current).GetNode());
}
示例6: DeserializeElement
protected override void DeserializeElement (XmlReader reader, bool serializeCollectionKey)
{
original = new XmlDocument ().ReadNode (reader);
node = original.CloneNode (true);
}
示例7: createNodeNormalizedMemento
private InstanceMemento createNodeNormalizedMemento(XmlNode node)
{
XmlNode clonedNode = node.CloneNode(true);
return new XmlNodeInstanceMemento(clonedNode, _typeAttribute, _keyAttribute);
}
示例8: NewTabPage
private TabPage NewTabPage(XmlNode xmlNode, bool isMain)
{
XmlNode inXmlNode = xmlNode.CloneNode(true);
SetMillisecondsIntoXml(inXmlNode);
if (inXmlNode.Attributes != null)
{
string s = inXmlNode.Attributes["elapsedMilliseconds"].Value.Replace(".", ",");
SetPercentIntoXml(inXmlNode, double.Parse(s));
}
var treePage = new TabPage {Height = tabControl.Height - 15, Width = tabControl.Width, Text = xmlNode.Name};
var treeView = new TreeView {Width = treePage.Width - 10, Height = treePage.Height - 10};
if (_dom.DocumentElement != null && isMain)
{
treeView.Nodes.Add(new TreeNode(_dom.DocumentElement.Name));
}
else
{
treeView.Nodes.Add(new TreeNode(xmlNode.Name));
}
TreeNode tNode = treeView.Nodes[0];
treeView.MouseClick += defTreeView_Click;
AddNode(inXmlNode, tNode);
treeView.ExpandAll();
treePage.Controls.Add(treeView);
return treePage;
}
示例9: CopyRow
/// <summary>
/// Copy the row in table
/// </summary>
/// <param name="count">The times of copy</param>
/// <param name="node">The node of row</param>
protected void CopyRow(int count, XmlNode node, XmlNamespaceManager xmlmgr)
{
for (int i = 0; i < count; i++)
{
this.TagInfo = string.Format("Insert new row:{0}/{1}", i.ToString(), count.ToString());
XmlNode newNode = node.CloneNode(true);
string rowname = "w:tc/w:p/w:r/w:t";
XmlNodeList nodelist = newNode.SelectNodes(rowname, xmlmgr);
foreach (XmlNode nodecell in nodelist)
{
string strvalue = nodecell.InnerText.Trim();
if (strvalue.StartsWith("$") && strvalue.Contains("{0}"))
{
nodecell.InnerXml = nodecell.InnerXml.Replace(nodecell.InnerText, string.Format(strvalue, i.ToString()));
}
}
ProcessTag(nodelist);
node.ParentNode.InsertBefore(newNode, node);
}
node.ParentNode.RemoveChild(node);
}
示例10: CreateFootnote
/// <summary>
/// Creates the footnote.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="node">The node.</param>
/// <returns></returns>
public Footnote CreateFootnote(IDocument document,XmlNode node)
{
try
{
Footnote fnote = new Footnote(document);
fnote.Node = node.CloneNode(true);
return fnote;
}
catch(Exception ex)
{
throw new AODLException("Exception while trying to create a Footnote.", ex);
}
}
示例11: LogRequest
public void LogRequest(XmlNode request, bool demo)
{
request = request.CloneNode(true);
MaskXml(SafeFields.MessageType.REQUEST, request, null);
string logString = request.OuterXml;
if (demo)
{
Console.WriteLine(DEMO_REQUEST_HEADER + logString + NEWLINE);
}
Log(LogType.REQUEST, logString );
}
示例12: CreateBookmark
/// <summary>
/// Creates the bookmark.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="node">The node.</param>
/// <param name="type">The type.</param>
/// <returns></returns>
public Bookmark CreateBookmark(IDocument document,XmlNode node, BookmarkType type)
{
try
{
Bookmark bookmark = null;
if (type == BookmarkType.Standard)
bookmark = new Bookmark(document, BookmarkType.Standard, "noname");
else if (type == BookmarkType.Start)
bookmark = new Bookmark(document, BookmarkType.Start, "noname");
else
bookmark = new Bookmark(document, BookmarkType.End, "noname");
bookmark.Node = node.CloneNode(true);
return bookmark;
}
catch(Exception ex)
{
throw new AODLException("Exception while trying to create a Bookmark.", ex);
}
}
示例13: CreateXLink
/// <summary>
/// Creates the X link.
/// </summary>
/// <param name="document">The document.</param>
/// <param name="node">The node.</param>
/// <returns></returns>
public XLink CreateXLink(IDocument document, XmlNode node)
{
try
{
XLink xlink = new XLink(document);
xlink.Node = node.CloneNode(true);
ITextCollection iTxtCol = new ITextCollection();
foreach(XmlNode nodeText in xlink.Node.ChildNodes)
{
IText iText = this.CreateTextObject(xlink.Document, nodeText);
if (iText != null)
iTxtCol.Add(iText);
}
xlink.Node.InnerXml = "";
foreach(IText iText in iTxtCol)
xlink.TextContent.Add(iText);
return xlink;
}
catch(Exception ex)
{
throw new AODLException("Exception while trying to create a XLink.", ex);
}
}
示例14: StripWhitespace
/// <summary>
/// Creates a new Node (of the same type as the original node)
/// that is similar to the orginal but doesn't contain any
/// empty text or CDATA nodes and where all textual content
/// including attribute values or comments are trimmed.
/// </summary>
public static XmlNode StripWhitespace(XmlNode original)
{
XmlNode cloned = original.CloneNode(true);
cloned.Normalize();
HandleWsRec(cloned, false);
return cloned;
}
示例15: Copy
private void Copy(XmlNode node)
{
TreeEditorViewModel.CopiedElement = node.CloneNode(true);
}