本文整理汇总了C#中System.Xml.XmlDocument.ImportNode方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.ImportNode方法的具体用法?C# System.Xml.XmlDocument.ImportNode怎么用?C# System.Xml.XmlDocument.ImportNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.ImportNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: svgconcat
bool svgconcat(List<string> files, string output, uint delay, uint loop) {
if (controller_ != null) controller_.appendOutput("TeX2img: Making animation svg...");
try {
var outxml = new System.Xml.XmlDocument();
outxml.XmlResolver = null;
outxml.AppendChild(outxml.CreateXmlDeclaration("1.0", "utf-8", "no"));
outxml.AppendChild(outxml.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
var svg = outxml.CreateElement("svg", "http://www.w3.org/2000/svg");
var attr = outxml.CreateAttribute("xmlns:xlink");
attr.Value = "http://www.w3.org/1999/xlink";
svg.Attributes.Append(attr);
attr = outxml.CreateAttribute("version");
attr.Value = "1.1";
svg.Attributes.Append(attr);
outxml.AppendChild(svg);
var defs = outxml.CreateElement("defs", "http://www.w3.org/2000/svg");
svg.AppendChild(defs);
var idreg = new System.Text.RegularExpressions.Regex(@"(?<!\&)#");
foreach (var f in files) {
var id = Path.GetFileNameWithoutExtension(f);
var xml = new System.Xml.XmlDocument();
xml.XmlResolver = null;
xml.Load(Path.Combine(workingDir, f));
foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("*")) {
foreach (System.Xml.XmlAttribute a in tag.Attributes) {
if (a.Name.ToLower() == "id") a.Value = id + "-" + a.Value;
else a.Value = idreg.Replace(a.Value, "#" + id + "-");
}
}
foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("svg")) {
var idattr = xml.CreateAttribute("id");
idattr.Value = id;
tag.Attributes.Append(idattr);
}
foreach (System.Xml.XmlNode n in xml.ChildNodes) {
if (n.NodeType != System.Xml.XmlNodeType.DocumentType && n.NodeType != System.Xml.XmlNodeType.XmlDeclaration) {
defs.AppendChild(outxml.ImportNode(n, true));
}
}
}
var use = outxml.CreateElement("use", "http://www.w3.org/2000/svg");
svg.AppendChild(use);
var animate = outxml.CreateElement("animate", "http://www.w3.org/2000/svg");
use.AppendChild(animate);
attr = outxml.CreateAttribute("attributeName");
attr.Value = "xlink:href"; animate.Attributes.Append(attr);
attr = outxml.CreateAttribute("begin");
attr.Value = "0s"; animate.Attributes.Append(attr);
attr = outxml.CreateAttribute("dur");
attr.Value = ((decimal)(delay * files.Count) / 100).ToString() + "s";
animate.Attributes.Append(attr);
attr = outxml.CreateAttribute("repeatCount");
attr.Value = loop > 0 ? loop.ToString() : "indefinite";
animate.Attributes.Append(attr);
attr = outxml.CreateAttribute("values");
attr.Value = String.Join(";", files.Select(d => "#" + Path.GetFileNameWithoutExtension(d)).ToArray());
animate.Attributes.Append(attr);
outxml.Save(Path.Combine(workingDir, output));
if (controller_ != null) controller_.appendOutput(" done\n");
return true;
}
catch (Exception) { return false; }
}
示例2: CreateDocWithoutSignature
/// <summary>
/// Create a new XmlDocument from the specified signed document removing the signature element.
/// </summary>
/// <param name="signedDoc"></param>
/// <returns></returns>
public static System.Xml.XmlDocument CreateDocWithoutSignature(System.Xml.XmlDocument signedDoc)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.ImportNode(signedDoc.DocumentElement, true));
System.Xml.XmlElement signature = GetSignatureFromSignedDoc(doc);
signature.ParentNode.RemoveChild(signature);
return doc;
}
示例3: ReturnApplicationLogItem
/// <summary>
/// Return a specific application log by Id.
/// </summary>
/// <param name="context">
/// An System.Web.HttpContext object that provides references to the intrinsic server objects (for example, Request, Response, Session, and
/// Server) used to service HTTP requests.
/// </param>
/// <param name="itemId">Id of the application log to return.</param>
private void ReturnApplicationLogItem(HttpContext context, int itemId)
{
var config = CoreWebConfiguration.Configuration.ApplicationLogRssFeed;
var connectionStringName = config.ConnectionString.Name;
if (string.IsNullOrWhiteSpace(connectionStringName))
{
connectionStringName = DefaultConnectionStringName;
}
var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName];
var applicationLogRepository = new ApplicationLogRepository(connectionString.ConnectionString);
var log = applicationLogRepository.GetById(itemId);
var xmlDocument = new System.Xml.XmlDocument();
var xmlNavigator = xmlDocument.CreateNavigator();
using (var writer = xmlNavigator.AppendChild())
{
var serializer = new DataContractSerializer(typeof(ApplicationLogDao));
serializer.WriteObject(writer, log);
}
if (null != log.Data.FirstChild)
{
var dataElement = xmlDocument.CreateElement("Data", xmlDocument.FirstChild.NamespaceURI);
var importedElement = xmlDocument.ImportNode(log.Data.FirstChild, true);
dataElement.AppendChild(importedElement);
xmlDocument.FirstChild.AppendChild(dataElement);
}
context.Response.ContentType = "text/xml";
context.Response.Output.Write(xmlDocument.InnerXml);
context.Response.StatusCode = (int) HttpStatusCode.OK;
context.Response.Flush();
}
示例4: CreateSignedDoc
/// <summary>
/// Create a signed xml document. Add a signature alement to the specified document using the specified private key.
/// </summary>
/// <param name="xmlToSign"></param>
/// <param name="keyPubPri">Private+public key</param>
/// <returns></returns>
public static System.Xml.XmlDocument CreateSignedDoc(System.Xml.XmlDocument xmlToSign, string keyPubPri)
{
System.Xml.XmlElement signature = CreateSignature(xmlToSign, keyPubPri);
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.AppendChild(doc.ImportNode(xmlToSign.DocumentElement, true));
//Append the signature tag to the root element
doc.DocumentElement.PrependChild(doc.ImportNode(signature, true));
return doc;
}