本文整理汇总了C#中System.Xml.XmlNamespaceManager类的典型用法代码示例。如果您正苦于以下问题:C# XmlNamespaceManager类的具体用法?C# XmlNamespaceManager怎么用?C# XmlNamespaceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlNamespaceManager类属于System.Xml命名空间,在下文中一共展示了XmlNamespaceManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: XmlParserContext
/// <include file='doc\XmlParserContext.uex' path='docs/doc[@for="XmlParserContext.XmlParserContext3"]/*' />
public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName,
String pubId, String sysId, String internalSubset, String baseURI,
String xmlLang, XmlSpace xmlSpace, Encoding enc)
{
if (nsMgr != null) {
if (nt == null) {
_nt = nsMgr.NameTable;
}
else {
if ( (object)nt != (object) nsMgr.NameTable ) {
throw new XmlException(Res.Xml_NotSameNametable);
}
_nt = nt;
}
}
else {
_nt = nt;
}
_nsMgr = nsMgr;
_docTypeName = (null == docTypeName ? String.Empty : docTypeName);
_pubId = (null == pubId ? String.Empty : pubId);
_sysId = (null == sysId ? String.Empty : sysId);
_internalSubset = (null == internalSubset ? String.Empty : internalSubset);
_baseURI = (null == baseURI ? String.Empty : baseURI);
_xmlLang = (null == xmlLang ? String.Empty : xmlLang);
_xmlSpace = xmlSpace;
_encoding = enc;
}
开发者ID:ArildF,项目名称:masters,代码行数:32,代码来源:xmlparsercontext.cs
示例2: from
public void from(XmlNode node, XmlNamespaceManager xnm, string prefix, string subfix)
{
Type type = this.GetType();
FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
foreach (FieldInfo field in fields)
{
string query = prefix +ObjectUtil.GetSimpleName(field) + subfix;
try
{
string value = null;
XmlNode tempNode;
if (xnm != null)
{
tempNode = node.SelectSingleNode(query, xnm);
}
else
{
tempNode = node.SelectSingleNode(query);
}
if (tempNode == null) {
field.SetValue(this,XML_NULL);
continue;
}
value = tempNode.InnerText;
field.SetValue(this, value);
}
catch (Exception ex) { }
}
}
开发者ID:uhealin,项目名称:toyz-toyz4net,代码行数:30,代码来源:BaseAdapter.cs
示例3: Evaluate
/// <summary>
/// Evaluates the given expression and returns the typed result.
/// </summary>
public static object Evaluate(string expression, XPathNavigator source,
XmlNamespaceManager context)
{
XPathExpression expr = GetCompiledExpression(expression, source);
expr.SetContext(context);
return source.Evaluate(expr);
}
开发者ID:Monobjc,项目名称:monobjc-tools,代码行数:10,代码来源:XPathCache.cs
示例4: TelemetryInitializerInstall
protected void TelemetryInitializerInstall(string sourceDocument, params string[] telemetryInitializerTypes)
{
string resourceName = "Microsoft.ApplicationInsights.Resources.ApplicationInsights.config.install.xdt";
Stream stream = typeof(ModuleTransformTests).Assembly.GetManifestResourceStream(resourceName);
using (StreamReader reader = new StreamReader(stream))
{
string transform = reader.ReadToEnd();
XmlTransformation transformation = new XmlTransformation(transform, false, null);
XmlDocument targetDocument = new XmlDocument();
targetDocument.LoadXml(sourceDocument);
transformation.Apply(targetDocument);
XmlNamespaceManager manager = new XmlNamespaceManager(new NameTable());
manager.AddNamespace("ai", AppInsightsNamespace);
int moduleIndex = 0;
foreach (XPathNavigator module in targetDocument.CreateNavigator().Select("/ai:ApplicationInsights/ai:TelemetryInitializers/ai:Add/@Type", manager))
{
string contextInitializerType = telemetryInitializerTypes[moduleIndex++];
Assert.Equal(module.Value, contextInitializerType);
}
Assert.Equal(moduleIndex, telemetryInitializerTypes.Length);
}
}
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:25,代码来源:TelemetryInitializerTransformTests.cs
示例5: ModifyPrintTicket
public static PrintTicket ModifyPrintTicket(PrintTicket ticket, string featureName, string newValue)
{
if (ticket == null)
{
throw new ArgumentNullException("ticket");
}
var xmlDoc = new XmlDocument();
xmlDoc.Load(ticket.GetXmlStream());
var manager = new XmlNamespaceManager(xmlDoc.NameTable);
manager.AddNamespace(xmlDoc.DocumentElement.Prefix, xmlDoc.DocumentElement.NamespaceURI);
var xpath = string.Format("//psf:Feature[contains(@name, 'InputBin')]/psf:Option", featureName);
var node = xmlDoc.SelectSingleNode(xpath, manager);
if (node != null)
{
node.Attributes["name"].Value = newValue;
}
var printTicketStream = new MemoryStream();
xmlDoc.Save(printTicketStream);
printTicketStream.Position = 0;
var modifiedPrintTicket = new PrintTicket(printTicketStream);
return modifiedPrintTicket;
}
开发者ID:modulexcite,项目名称:printengine,代码行数:26,代码来源:XpsPrinterUtils.cs
示例6: Main
static void Main( string[] args )
{
if ( args.Length != 1 )
{
return;
}
string fileName = args[ 0 ];
StringBuilder fileContent = new StringBuilder( System.IO.File.ReadAllText( fileName ) );
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml( fileContent.ToString() );
System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager( xdoc.NameTable );
xmlnsManager.AddNamespace( "gpx", "http://www.topografix.com/GPX/1/0" );
XmlNodeList timeNodes = xdoc.SelectNodes( "//gpx:time", xmlnsManager );
foreach ( XmlNode timeNode in timeNodes )
{
string[] split1 = timeNode.InnerText.Split( 'T' );
string[] splitDays = split1[ 0 ].Split( '-' );
string[] splitHours = split1[ 1 ].Replace( "Z", "" ).Split( ':' );
fileContent.Replace( timeNode.InnerText, new DateTime( int.Parse( splitDays[ 0 ] ), int.Parse( splitDays[ 1 ] ), int.Parse( splitDays[ 2 ] ),
int.Parse( splitHours[ 0 ] ), int.Parse( splitHours[ 1 ] ), int.Parse( splitHours[ 2 ] ) ).ToUniversalTime().ToString( "s" ) + "Z" );
}
System.IO.File.WriteAllText( fileName.Replace( ".gpx", "-fix.gpx" ), fileContent.ToString() );
}
开发者ID:cbarbara,项目名称:RunKeeperGPXFixer,代码行数:28,代码来源:Program.cs
示例7: CancelAppointment
public bool CancelAppointment(HackExchangeContext context, CalendarItem appointment)
{
var url = context.Endpoint;
var request = new HttpRequestMessage(HttpMethod.Post, url);
var postBodyTemplate = LoadXml("CancelAppointment");
var postBody = string.Format(postBodyTemplate, appointment.Id, appointment.ChangeKey);
request.Content = new StringContent(postBody, Encoding.UTF8, "text/xml");
var clientHandler = new HttpClientHandler()
{
Credentials = context.Credentials
};
using (var client = new HttpClient(clientHandler))
{
var response = client.SendAsync(request).Result;
var responseBody = response.Content.ReadAsStringAsync().Result;
var doc = new XPathDocument(new StringReader(responseBody));
var nav = doc.CreateNavigator();
var nsManager = new XmlNamespaceManager(nav.NameTable);
nsManager.AddNamespace("m", "http://schemas.microsoft.com/exchange/services/2006/messages");
nsManager.AddNamespace("t", "http://schemas.microsoft.com/exchange/services/2006/types");
var responseClass = EvaluateXPath(nav, nsManager, "//m:DeleteItemResponseMessage/@ResponseClass");
return responseClass == "Success";
}
}
开发者ID:arriori,项目名称:Hackweek2,代码行数:27,代码来源:HackExchangeService.cs
示例8: Feed
public Feed(IXPathNavigable navigable)
{
navigator = navigable.CreateNavigator();
manager = new XmlNamespaceManager(navigator.NameTable);
manager.AddNamespace("f", "http://hl7.org/fhir");
manager.AddNamespace("atom", "http://www.w3.org/2005/Atom");
}
开发者ID:wdebeau1,项目名称:fhir-net-api,代码行数:7,代码来源:FhirFeed.cs
示例9: GetValue
public string GetValue(XElement element, XmlNamespaceManager nsm)
{
XPathContext context = new XPathContext((NameTable)nsm.NameTable);
XPathNavigator navigator = element.CreateNavigator();
object result = null;
foreach (var ns in nsm.GetNamespacesInScope(XmlNamespaceScope.All))
context.AddNamespace(ns.Key, ns.Value);
context.Arguments.AddParam(XPathContext.ParameterNames.CurrentNode, string.Empty, navigator.Select("."));
result = navigator.Evaluate(this.RawValue, context);
if (result is string)
return (string)result;
else if (result is XPathNodeIterator)
{
var iterator = ((XPathNodeIterator)result);
var current = (XPathNavigator)((IEnumerable)iterator).Cast<object>().First();
return current.Value;
}
else if (result is XAttribute)
return ((XAttribute)result).Value;
else if (result is XElement)
return ((XElement)result).Value;
return string.Empty;
}
开发者ID:QuantumConcepts,项目名称:CodeGenerator,代码行数:28,代码来源:ComingledXPathExpressionXPathPart.cs
示例10: XmlException
SelectRequiredSingleNode
(
XmlNode node,
String xPath,
XmlNamespaceManager xmlNamespaceManager
)
{
Debug.Assert(node != null);
Debug.Assert( !String.IsNullOrEmpty(xPath) );
XmlNode oSelectedNode;
if ( !TrySelectSingleNode(node, xPath, xmlNamespaceManager,
out oSelectedNode) )
{
throw new XmlException( String.Format(
"An XML node with the name \"{0}\" is missing a required"
+ " descendent node. The XPath is \"{1}\"."
,
node.Name,
xPath
) );
}
return (oSelectedNode);
}
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:27,代码来源:XmlUtil2.cs
示例11: Initialize
public void Initialize(XmlDocument basedata, XmlNamespaceManager namespaces, RDFTriple rdftriple)
{
BaseData = basedata;
Namespaces = namespaces;
RDFTriple = rdftriple;
UploadInfoToORCID1.Initialize(basedata, namespaces, rdftriple);
}
开发者ID:nicholaswilliambrown,项目名称:ProfilesRNS_ORCID,代码行数:7,代码来源:CreateMyORCID.ascx.cs
示例12: QueryAndNamespace
public void QueryAndNamespace()
{
try
{
var output = "";
var path = Server.MapPath("~/App_Data/bookstore.xml");
XPathDocument document = new XPathDocument(path);
XPathNavigator navigator = document.CreateNavigator();
XPathExpression query = navigator.Compile("/bookstore:bookstore/bookstore:book");
XmlNamespaceManager manager = new XmlNamespaceManager(navigator.NameTable);
manager.AddNamespace("bookstore", "urn:newbooks-schema");
query.SetContext(manager);
XPathNodeIterator nodes = navigator.Select(query);
while (nodes.MoveNext())
{
output += nodes.Current.OuterXml;
}
Textarea4.InnerHtml = output;
}
catch (Exception ex)
{
Textarea4.InnerHtml = ex.Message;
}
}
开发者ID:Karolinebryn,项目名称:SampleCodeCertification70-487,代码行数:26,代码来源:UsingTheXpathDataModel.aspx.cs
示例13: PatchSystemFolder_Add
private static void PatchSystemFolder_Add(string typeName, params string[] additionalContentTypeNames)
{
var ct = ContentType.GetByName(typeName);
var xml = new XmlDocument();
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("x", ContentType.ContentDefinitionXmlNamespace);
xml.Load(ct.Binary.GetStream());
var list = new List<string>();
var element = (XmlElement)xml.DocumentElement.SelectSingleNode("x:AllowedChildTypes", nsmgr);
if (element == null)
{
var fieldsElement = (XmlElement)xml.DocumentElement.SelectSingleNode("x:Fields", nsmgr);
//if (fieldsElement == null)
//{
//}
element = xml.CreateElement("", "AllowedChildTypes", ContentType.ContentDefinitionXmlNamespace);
xml.DocumentElement.InsertBefore(element, fieldsElement);
}
else
{
list.AddRange(element.InnerXml.Split(" \t\r\n,;".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries).Select(x=>x.Trim()));
}
if (additionalContentTypeNames != null && additionalContentTypeNames.Length > 0)
list.AddRange(additionalContentTypeNames);
element.InnerText = string.Join(" ", list);
ContentTypeInstaller.InstallContentType(xml.OuterXml);
}
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:29,代码来源:Initializer.cs
示例14: ResinConf
public ResinConf(String file)
{
_xPathDoc = new XPathDocument(file);
_docNavigator = _xPathDoc.CreateNavigator();
_xmlnsMgr = new XmlNamespaceManager(_docNavigator.NameTable);
_xmlnsMgr.AddNamespace("caucho", "http://caucho.com/ns/resin");
}
开发者ID:dpitkevics,项目名称:php-to-scala-migration-helper,代码行数:7,代码来源:ResinConf.cs
示例15: Execute
public override bool Execute()
{
try {
var document = new XmlDocument();
document.Load(this.XmlFileName);
var navigator = document.CreateNavigator();
var nsResolver = new XmlNamespaceManager(navigator.NameTable);
if (!string.IsNullOrEmpty(this.Prefix) && !string.IsNullOrEmpty(this.Namespace)) {
nsResolver.AddNamespace(this.Prefix, this.Namespace);
}
var expr = XPathExpression.Compile(this.XPath, nsResolver);
var iterator = navigator.Select(expr);
while (iterator.MoveNext()) {
iterator.Current.DeleteSelf();
}
using (var writer = new XmlTextWriter(this.XmlFileName, Encoding.UTF8)) {
writer.Formatting = Formatting.Indented;
document.Save(writer);
writer.Close();
}
}
catch (Exception exception) {
base.Log.LogErrorFromException(exception);
return false;
}
base.Log.LogMessage("Updated file '{0}'", new object[] { this.XmlFileName });
return true;
}
开发者ID:gokhandisikara,项目名称:Coevery-Framework,代码行数:33,代码来源:XmlDelete.cs
示例16: XmlValidationRule
public XmlValidationRule(IXmlDocumentProvider docProvider, XmlNode node, XmlNamespaceManager nsmgr)
{
if (node.Attributes["name"] != null)
Name = node.Attributes["name"].Value;
if (node.Attributes["file"] != null)
File = node.Attributes["file"].Value;
if (!string.IsNullOrEmpty(File))
{
try
{
XmlDocument doc = docProvider.Load(File);
if (doc != null)
{
List<ITest> tests = new List<ITest>();
string prefix = nsmgr.LookupPrefix("http://icalvalid.wikidot.com/validation");
foreach (XmlNode passNode in doc.SelectNodes("/" + prefix + ":rule/" + prefix + ":pass", nsmgr))
tests.Add(new XmlCalendarTest(passNode, nsmgr));
foreach (XmlNode failNode in doc.SelectNodes("/" + prefix + ":rule/" + prefix + ":fail", nsmgr))
tests.Add(new XmlCalendarTest(failNode, nsmgr));
Tests = tests.ToArray();
}
else throw new ValidationRuleLoadException("The file could not be found at the following path: '" + File + "'.", this);
}
catch (ValidationRuleLoadException) { throw; }
catch
{
throw new ValidationRuleLoadException(this);
}
}
}
开发者ID:ddaysoftware,项目名称:icalvalid,代码行数:33,代码来源:XmlValidationRule.cs
示例17: Load
public bool Load(XPathNavigator source, XmlNamespaceManager manager)
{
//------------------------------------------------------------
// Validate parameter
//------------------------------------------------------------
Guard.ArgumentNotNull(source, "source");
//------------------------------------------------------------
// Attempt to extract syndication information
//------------------------------------------------------------
ResourceName = source.LocalName;
Namespace = source.NamespaceURI;
string value;
Key = source.TryGetAttribute("key", Framework.Common.SData.Namespace, out value) ? value : null;
Uri = source.TryGetAttribute("uri", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Uri(value) : null;
Uuid = source.TryGetAttribute("uuid", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? new Guid(value) : (Guid?) null;
Descriptor = source.TryGetAttribute("descriptor", Framework.Common.SData.Namespace, out value) ? value : null;
Lookup = source.TryGetAttribute("lookup", Framework.Common.SData.Namespace, out value) ? value : null;
IsDeleted = source.TryGetAttribute("isDeleted", Framework.Common.SData.Namespace, out value) && !string.IsNullOrEmpty(value) ? XmlConvert.ToBoolean(value) : (bool?) null;
return source.SelectChildren(XPathNodeType.Element)
.Cast<XPathNavigator>()
.GroupBy(item => item.LocalName)
.All(group => LoadItem(group.Key, group, manager));
}
开发者ID:jasonhuber,项目名称:SDataUpdateNestedEntities,代码行数:26,代码来源:SDataPayload.cs
示例18: Parse
public static CT_Border Parse(XmlNode node, XmlNamespaceManager namespaceManager)
{
if (node == null)
return null;
CT_Border ctObj = new CT_Border();
ctObj.diagonalUp = XmlHelper.ReadBool(node.Attributes["diagonalUp"]);
ctObj.diagonalDown = XmlHelper.ReadBool(node.Attributes["diagonalDown"]);
ctObj.outline = XmlHelper.ReadBool(node.Attributes["outline"]);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == "left")
ctObj.left = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "right")
ctObj.right = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "top")
ctObj.top = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "bottom")
ctObj.bottom = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "diagonal")
ctObj.diagonal = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "vertical")
ctObj.vertical = CT_BorderPr.Parse(childNode, namespaceManager);
else if (childNode.LocalName == "horizontal")
ctObj.horizontal = CT_BorderPr.Parse(childNode, namespaceManager);
}
return ctObj;
}
开发者ID:kahinke,项目名称:npoi,代码行数:27,代码来源:CT_Border.cs
示例19: CopyNodes
/// <summary>
/// Copys the same nodes under a parent node from one document to a second
/// </summary>
/// <param name="oDocDonor">Xml Doc to copy the nodes from</param>
/// <param name="oDocReceiver">Xml Doc to copy the nodes to</param>
/// <param name="xPath">Generic namespaces are automatically applied. use ns: as namespace for each node.</param>
/// <returns></returns>
private static int CopyNodes(XmlDocument oDocReceiver, XmlDocument oDocDonor, string xPath)
{
var namespaceManagerReceiver = new XmlNamespaceManager(oDocReceiver.NameTable);
namespaceManagerReceiver.AddNamespace("ns", oDocReceiver.DocumentElement.NamespaceURI);
var namespaceManagerDonor = new XmlNamespaceManager(oDocDonor.NameTable);
namespaceManagerDonor.AddNamespace("ns", oDocDonor.DocumentElement.NamespaceURI);
var testDefinitionNode = oDocDonor.SelectSingleNode(xPath, namespaceManagerDonor);
if (testDefinitionNode == null)
{
throw new InvalidDataException("Donor document misses node for xpath " + xPath);
}
var testDefinitionNodeReceiver = oDocReceiver.SelectSingleNode(xPath, namespaceManagerReceiver);
if (testDefinitionNodeReceiver == null)
{
throw new InvalidDataException("Receiver document misses node for xpath " + xPath);
}
int copied = 0;
foreach (XmlNode node in testDefinitionNode.ChildNodes)
{
XmlNode newChildNode = oDocReceiver.ImportNode(node, true);
testDefinitionNodeReceiver.AppendChild(newChildNode);
copied++;
}
return copied;
}
开发者ID:Autom8edChaos,项目名称:BetterTrxMerger,代码行数:34,代码来源:TrxMerger.cs
示例20: CreateReport
private void CreateReport(IDictionary idc, string rptStyle)
{
var sp1 = new SpreadsheetClass();
var doc = new XmlDocument();
doc.LoadXml(rptStyle);
var xn = new XmlNamespaceManager(doc.NameTable);
xn.AddNamespace("ss", "urn:schemas-microsoft-com:office:spreadsheet");
var nodes = doc.SelectNodes("//ss:Data", xn);
//根据key替换数据
foreach (XmlNode node in nodes)
{
var tmpValue = node.InnerText.Trim();
if (tmpValue.Length > 2 && tmpValue.Substring(0, 1) == "♂")
{
string val = tmpValue.Substring(1);
node.InnerText = idc.Contains(val) ? idc[val].ToString() : string.Empty;
rptStyle = rptStyle.Replace(tmpValue, node.InnerText);
}
}
//sp1.XMLData = style;
sp1.XMLData = doc.OuterXml;
//dvShow.InnerHtml = sp1.HTMLData;
sp1.XMLData = sp1.XMLData.ToString().Replace("<ss:Table", "<ss:Table ss:id=\"CX\"");
Response.Write(sp1.HTMLData);
}
开发者ID:eseawind,项目名称:sac-hnss,代码行数:31,代码来源:ReportTreeProxy.aspx.cs
注:本文中的System.Xml.XmlNamespaceManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论