当前位置: 首页>>代码示例>>C#>>正文


C# Xml.XmlNamespaceManager类代码示例

本文整理汇总了C#中System.Xml.XmlNamespaceManager的典型用法代码示例。如果您正苦于以下问题:C# XmlNamespaceManager类的具体用法?C# XmlNamespaceManager怎么用?C# XmlNamespaceManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XmlNamespaceManager类属于System.Xml命名空间,在下文中一共展示了XmlNamespaceManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的System.Xml.XmlNamespaceManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。