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


C# XmlNamespaceManager.AddNamespace方法代码示例

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


在下文中一共展示了XmlNamespaceManager.AddNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Listar

        /// <summary>
        /// Metodo para carregar os dados.
        /// </summary>
        /// <returns></returns>
        public List<YoutubeFeedItem> Listar()
        {
            string url = String.Format("https://gdata.youtube.com/feeds/api/videos?author={0}&orderby=published&start-index=11&max-results={1}&v=2&fields=entry(title,published,link,media:group(media:thumbnail, media:description))", this.Username, this.Lines);
            XmlDocument xmlDoc = this.GetXmlDocument(url);

            /// Uma peculiaridade deste codico é que o retorno do XML traz a definição
            /// de uma namespace implicita, assim como outras. Ou seja, se não regitrarmos
            /// as namespaces e depois as referenciarmos, a engine não irá encontrar
            /// os lementos especificados nos xpath.
            XmlNamespaceManager nsManager = new XmlNamespaceManager(xmlDoc.NameTable);
            nsManager.AddNamespace("atom", "http://www.w3.org/2005/Atom");
            nsManager.AddNamespace("media", "http://search.yahoo.com/mrss/");
            nsManager.AddNamespace("yt", "http://gdata.youtube.com/schemas/2007");

            List<YoutubeFeedItem> resultados = new List<YoutubeFeedItem>();

            foreach (XmlNode node in xmlDoc.SelectNodes("//atom:entry", nsManager))
            {
                resultados.Add(new YoutubeFeedItem()
                {
                    Text = node.SelectSingleNode("atom:title", nsManager).InnerText,
                    Link = node.SelectSingleNode("atom:link[@type='text/html']", nsManager).Attributes["href"].Value,
                    Description = node.SelectSingleNode("media:group/media:description", nsManager).InnerText,
                    Thumbnail = node.SelectSingleNode("media:group/media:thumbnail", nsManager).Attributes["url"].Value,
                    Published = DateTime.Parse(node.SelectSingleNode("atom:published", nsManager).InnerText)
                });
            }

            return resultados;
        }
开发者ID:rodrigokono,项目名称:DevGoias,代码行数:34,代码来源:YoutubeFeedReader.cs

示例2: GetTitle

        /// <summary>
        /// Tries to extract the BluRay title.
        /// </summary>
        /// <returns></returns>
        public string GetTitle()
        {
            string metaFilePath = Path.Combine(DirectoryBDMV.FullName, @"META\DL\bdmt_eng.xml");
              if (!File.Exists(metaFilePath))
            return null;

              try
              {
            XPathDocument metaXML = new XPathDocument(metaFilePath);
            XPathNavigator navigator = metaXML.CreateNavigator();
            if (navigator.NameTable != null)
            {
              XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable);
              ns.AddNamespace("", "urn:BDA:bdmv;disclib");
              ns.AddNamespace("di", "urn:BDA:bdmv;discinfo");
              navigator.MoveToFirst();
              XPathNavigator node = navigator.SelectSingleNode("//di:discinfo/di:title/di:name", ns);
              if (node != null)
            return node.ToString().Trim();
            }
              }
              catch (Exception e)
              {
            ServiceRegistration.Get<ILogger>().Error("BDMEx: Meta File Error: ", e);
              }
              return null;
        }
开发者ID:fokion,项目名称:MediaPortal-2,代码行数:31,代码来源:BDInfoExt.cs

示例3: 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

示例4: PrepareComponentUpdateXml

        private static string PrepareComponentUpdateXml(string xmlpath, IDictionary<string, string> paths)
        {
            string xml = File.ReadAllText(xmlpath);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
            manager.AddNamespace("avm", "avm");
            manager.AddNamespace("cad", "cad");

            XPathNavigator navigator = doc.CreateNavigator();
            var resourceDependencies = navigator.Select("/avm:Component/avm:ResourceDependency", manager).Cast<XPathNavigator>()
                .Concat(navigator.Select("/avm:Component/ResourceDependency", manager).Cast<XPathNavigator>());
            
            foreach (XPathNavigator node in resourceDependencies)
            {
                string path = node.GetAttribute("Path", "avm");
                if (String.IsNullOrWhiteSpace(path))
                {
                    path = node.GetAttribute("Path", "");
                }
                string newpath;
                if (paths.TryGetValue(node.GetAttribute("Name", ""), out newpath))
                {
                    node.MoveToAttribute("Path", "");
                    node.SetValue(newpath);
                }
            }
            StringBuilder sb = new StringBuilder();
            XmlTextWriter w = new XmlTextWriter(new StringWriter(sb));
            doc.WriteContentTo(w);
            w.Flush();
            return sb.ToString();
        }
开发者ID:neemask,项目名称:meta-core,代码行数:35,代码来源:CyPhyMLPropagateTest.cs

示例5: CreateManager

 public static XmlNamespaceManager CreateManager(XmlNameTable table)
 {
     XmlNamespaceManager mgr = new XmlNamespaceManager(table);
     mgr.AddNamespace(Options_Prefix, Options);
     mgr.AddNamespace(SongBook_Prefix, SongBook);
     return mgr;
 }
开发者ID:BackupTheBerlios,项目名称:zp7-svn,代码行数:7,代码来源:XmlNamespaces.cs

示例6: GetClickOnceInfo

 internal static string[] GetClickOnceInfo(ref string manifestPath, bool scanRemote, ref bool isUncPath, ref bool isHttpPath)
 {
     string[] strArray = new string[2];
       string str1 = string.Empty;
       string baseDir = string.Empty;
       string str2 = string.Empty;
       XmlDocument deployDoc = new XmlDocument();
       if (manifestPath == null || manifestPath.Length == 0)
     throw new ArgumentException(Resources.EMPTY_MANIFESTPATH);
       try
       {
     Uri uri = new Uri(manifestPath);
     bool flag;
     if (uri.IsLoopback)
       flag = ManifestReader.GetManifestFromLocalPath(deployDoc, ref manifestPath, out baseDir);
     else if (uri.IsUnc)
     {
       isUncPath = true;
       flag = scanRemote && ManifestReader.GetManifestFromUncPath(deployDoc, ref manifestPath, out baseDir);
     }
     else if (uri.Host != null && uri.Host.Length > 0)
     {
       isHttpPath = true;
       flag = scanRemote && ManifestReader.GetManifestFromHttpUrlPath(manifestPath, deployDoc, out baseDir);
     }
     else
       flag = false;
     if (flag)
     {
       XmlNamespaceManager nsmgr = new XmlNamespaceManager(deployDoc.NameTable);
       nsmgr.AddNamespace("asmv1", "urn:schemas-microsoft-com:asm.v1");
       nsmgr.AddNamespace("def", "urn:schemas-microsoft-com:asm.v2");
       XmlNode xmlNode1 = (XmlNode) deployDoc.DocumentElement;
       XmlNode xmlNode2 = xmlNode1.SelectSingleNode("/asmv1:assembly/def:dependency/def:dependentAssembly", nsmgr);
       XmlNode xmlNode3 = xmlNode1.SelectSingleNode("/asmv1:assembly/def:dependency/def:dependentAssembly/def:assemblyIdentity", nsmgr);
       string path2_1 = xmlNode2.Attributes["codebase"].Value;
       string path2_2 = xmlNode3.Attributes["name"].Value;
       str2 = xmlNode3.Attributes["version"].Value;
       if (isHttpPath)
       {
     string str3 = (baseDir + path2_1).Replace("\\", "/");
     str1 = str3.Substring(0, str3.LastIndexOf(".manifest")) + ".deploy";
       }
       else
     str1 = Path.Combine(Path.GetDirectoryName(Path.Combine(baseDir, path2_1)), path2_2) + ".deploy";
     }
     else
     {
       str1 = (string) null;
       str2 = (string) null;
     }
       }
       catch (Exception ex)
       {
     Globals.AddException(ex);
       }
       strArray[0] = str1;
       strArray[1] = str2;
       return strArray;
 }
开发者ID:mattlorimor,项目名称:AddInSpy,代码行数:60,代码来源:ManifestReader.cs

示例7: ApplyToContent

        public bool ApplyToContent(string rootFolder)
        {
            var fullPath = rootFolder + @"\" + AppxRelativePath;
            if (!File.Exists(fullPath))
            {
                return false;
            }

            var document = new XmlDocument();
            document.XmlResolver = null;

            using (var textReader = new XmlTextReader(fullPath))
            {
                textReader.DtdProcessing = DtdProcessing.Ignore;
                document.Load(textReader);
            }

            var navigator = document.CreateNavigator();
            var xmlnsManager = new System.Xml.XmlNamespaceManager(document.NameTable);
            xmlnsManager.AddNamespace("std", "http://schemas.microsoft.com/appx/manifest/foundation/windows10");
            xmlnsManager.AddNamespace("mp", "http://schemas.microsoft.com/appx/2014/phone/manifest");
            xmlnsManager.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10");
            xmlnsManager.AddNamespace("iot", "http://schemas.microsoft.com/appx/manifest/iot/windows10");
            xmlnsManager.AddNamespace("build", "http://schemas.microsoft.com/developer/appx/2015/build");

            var node = navigator.SelectSingleNode(XPath, xmlnsManager);
            node.SetValue(Value);

            document.Save(fullPath);
            return true;
        }
开发者ID:ms-iot,项目名称:iot-utilities,代码行数:31,代码来源:XmlContentChanges.cs

示例8: HoveddokumentStarterMedEtTallXsdValidererIkke

            public void HoveddokumentStarterMedEtTallXsdValidererIkke()
            {
                var arkiv = DomeneUtility.GetAsicEArkivEnkel();

                var signaturXml = arkiv.Signatur.Xml();
                var signaturvalidator = new Signaturvalidator();

                //Endre id på hoveddokument til å starte på et tall
                var namespaceManager = new XmlNamespaceManager(signaturXml.NameTable);
                namespaceManager.AddNamespace("ds", NavneromUtility.XmlDsig);
                namespaceManager.AddNamespace("ns10", NavneromUtility.UriEtsi121);
                namespaceManager.AddNamespace("ns11", NavneromUtility.UriEtsi132);

                var hoveddokumentReferanseNode = signaturXml.DocumentElement
                    .SelectSingleNode("//ds:Reference[@Id = '" + DomeneUtility.GetHoveddokumentEnkel().Id + "']",
                        namespaceManager);

                var gammelVerdi = hoveddokumentReferanseNode.Attributes["Id"].Value;
                hoveddokumentReferanseNode.Attributes["Id"].Value = "0_Id_Som_Skal_Feile";

                var validerer = signaturvalidator.ValiderDokumentMotXsd(signaturXml.OuterXml);
                Assert.IsFalse(validerer, signaturvalidator.ValideringsVarsler);

                hoveddokumentReferanseNode.Attributes["Id"].Value = gammelVerdi;
            }
开发者ID:pereilif,项目名称:sikker-digital-post-klient-dotnet,代码行数:25,代码来源:SignaturTester.cs

示例9: CreateNamespaceManager

        /// <summary>
        /// Creates a <see cref="XmlNamespaceManager"/> for <paramref name="document"/>.
        /// Namespaces declared in the document node are automatically added.
        /// The default namespace is given the prefix 'ns'.
        /// </summary>
        public static XmlNamespaceManager CreateNamespaceManager(this XmlDocument document)
        {
            var manager = new XmlNamespaceManager(document.NameTable);

            foreach (XmlNode node in document.SelectNodes("//node()"))
            {
                if (node is XmlElement)
                {
                    var element = node as XmlElement;

                    foreach (XmlAttribute attribute in element.Attributes)
                    {
                        if (attribute.Name == "xmlns")
                        {
                            // The first default namespace wins
                            // (since using multiple default namespaces in a single file is not considered a good practice)
                            if (!manager.HasNamespace("ns"))
                            {
                                manager.AddNamespace("ns", attribute.Value);
                            }
                        }

                        if (attribute.Prefix == "xmlns")
                        {
                            manager.AddNamespace(attribute.LocalName, attribute.Value);
                        }
                    }
                }
            }

            return manager;
        }
开发者ID:rh,项目名称:mix,代码行数:37,代码来源:XmlDocumentExtensions.cs

示例10: CheckBoxContentControl

        /*-------------------------------------------------------------------------------------------------------
        ** Constructors
        **-----------------------------------------------------------------------------------------------------*/
        
        public CheckBoxContentControl(ApplicationField ApplicationField)
            : base(ApplicationField)
        {
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(ApplicationField.Parameters[0]);

            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xml.NameTable);
            namespaceManager.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            namespaceManager.AddNamespace("w14", "http://schemas.microsoft.com/office/word/2010/wordml");

            XmlNodeList xnList = xml.SelectNodes("/w:sdt/w:sdtPr/w14:checkbox", namespaceManager);

            foreach (XmlNode xn in xnList)
            {
                foreach (XmlNode subnode in xn.ChildNodes)
                {
                    switch (subnode.LocalName)
                    {
                        case "checked":
                            if (subnode.Attributes["w14:val"] != null)
                                _bChecked = ((Convert.ToInt32(subnode.Attributes["w14:val"].Value) != 0));
                            break;
                    }
                }
            }
        }
开发者ID:StandardLaw,项目名称:TextControl.DocumentServer.MS-Word-Content-Controls-Field-Adapter-Classes,代码行数:30,代码来源:CheckBoxContentControl.cs

示例11: ArtifactResponse

        /// <summary>
        /// Initializes a new instance of the ArtifactResponse class.
        /// </summary>
        /// <param name="artifactResponse">
        /// String representation of the ArtifactResponse xml.
        /// </param>
        public ArtifactResponse(string artifactResponse)
        {
            try
            {
                xml = new XmlDocument();
                xml.PreserveWhitespace = true;
                xml.LoadXml(artifactResponse);
                nsMgr = new XmlNamespaceManager(xml.NameTable);
                nsMgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
                nsMgr.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
                nsMgr.AddNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");

                string xpath = "/samlp:ArtifactResponse/samlp:Response";
                XmlNode response = xml.DocumentElement.SelectSingleNode(xpath, nsMgr);
                if (response == null)
                {
                    throw new Saml2Exception(Resources.ArtifactResponseMissingResponse);
                }

                authnResponse = new AuthnResponse(response.OuterXml);
            }
            catch (ArgumentNullException ane)
            {
                throw new Saml2Exception(Resources.ArtifactResponseNullArgument, ane);
            }
            catch (XmlException xe)
            {
                throw new Saml2Exception(Resources.ArtifactResponseXmlException, xe);
            }
        }
开发者ID:agascon,项目名称:Fedlet,代码行数:36,代码来源:ArtifactResponse.cs

示例12: LoadFromXml

        public void LoadFromXml(XmlNode node)
        {
            this.DocInfo = new MmlDocumentInfo(node.SelectSingleNode("docInfo"));
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(node.OwnerDocument.NameTable);

            XmlNode content = node.SelectSingleNode("content");
            if (this.DocInfo.ContentModuleType == "patientInfo") {
                nsmgr.AddNamespace(MmlPi.PatientModule.NameSpacePrefix, MmlPi.PatientModule.NameSpaceURI);
                this.Content = new MmlPi.PatientModule(content.SelectSingleNode("mmlPi:PatientModule",nsmgr));
            } else if (this.DocInfo.ContentModuleType == "healthInsurance") {
                nsmgr.AddNamespace(MmlHi.HealthInsurance.NameSpacePrefix, MmlHi.HealthInsurance.NameSpaceURI);
                this.Content = new MmlHi.HealthInsurance(content.SelectSingleNode("mmlHi:HealthInsuranceModule", nsmgr));
            } else if (this.DocInfo.ContentModuleType == "registeredDiagnosis") {
                nsmgr.AddNamespace(MmlRd.RegisteredDiagnosisModule.NameSpacePrefix, MmlRd.RegisteredDiagnosisModule.NameSpaceURI);
                this.Content = new MmlRd.RegisteredDiagnosisModule(content.SelectSingleNode("mmlRd:RegisteredDiagnosisModule", nsmgr));
            } else if (this.DocInfo.ContentModuleType == "lifestyle") {
            } else if (this.DocInfo.ContentModuleType == "baseClinic") {
            } else if (this.DocInfo.ContentModuleType == "firstClinic") {
            } else if (this.DocInfo.ContentModuleType == "progressCourse") {
            } else if (this.DocInfo.ContentModuleType == "surgery") {
            } else if (this.DocInfo.ContentModuleType == "summary") {
            } else if (this.DocInfo.ContentModuleType == "claim") {
                nsmgr.AddNamespace(Claim.ClaimModule.NameSpacePrefix, Claim.ClaimModule.NameSpaceURI);
                this.Content = new Claim.ClaimModule(content.SelectSingleNode("claim:ClaimModule", nsmgr));
            } else if (this.DocInfo.ContentModuleType == "claimAmount") {
            } else if (this.DocInfo.ContentModuleType == "referral") {
            } else if (this.DocInfo.ContentModuleType == "test") {
            } else if (this.DocInfo.ContentModuleType == "report") {
            } else {
                throw new XmlException("ContentModuleTypeが対象外です。:" + this.DocInfo.ContentModuleType);
            }
        }
开发者ID:anhlai,项目名称:EMR-MML,代码行数:32,代码来源:MmlModuleItem.cs

示例13: Main

        static void Main(string[] args)
        {
            // Massive mem use here somewhere - about 1 GB
            var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            var gmlDoc = new XmlDocument();
            gmlDoc.Load(Path.Combine(userProfile, ConfigurationManager.AppSettings["GeographyFile"]));
            var ns = new XmlNamespaceManager(gmlDoc.NameTable);
            ns.AddNamespace("gml", "http://www.opengis.net/gml");
            ns.AddNamespace("fme", "http://www.safe.com/gml/fme");
            var nodes = gmlDoc.SelectNodes("/gml:FeatureCollection/gml:featureMember", ns);

            var boundaries = new List<BoundaryItem>();
            foreach (XmlNode node in nodes)
            {
                boundaries.Add(new BoundaryItem(ns, node));
            }

            var collection = new BoundaryItemCollection();
            collection.SetItems(boundaries);
            var importer = new NpgsqlBulkImporter(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString);
            importer.BulkImport("subdivisions", collection);
            Console.WriteLine("Bulk update complete");

            using (var wrapper = new NpgsqlConnectionWrapper(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString))
            {
                wrapper.Connection.Open();
                var rowsGeoUpdated = wrapper.ExecuteNonQuery("update subdivisions s set (boundry) = ((select ST_FlipCoordinates(ST_GeomFromGML(boundary_gml, 4269)) from subdivisions ss where s.id = ss.id))");
                Console.WriteLine($"Updated {rowsGeoUpdated} rows geo data from GML data");
            }

            Console.WriteLine("Node count {0}", nodes.Count);
        }
开发者ID:claq2,项目名称:Spurious,代码行数:32,代码来源:Program.cs

示例14: Router

 static Router()
 {
     namespaceManager = new XmlNamespaceManager(new NameTable());
     namespaceManager.AddNamespace("cnf", "http://cnf/Integration");
     namespaceManager.AddNamespace("cnfMgr", "http://cnf/ConfirmationsManager");
     namespaceManager.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
 }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:7,代码来源:Router.cs

示例15: OnActivate

        public override bool OnActivate()
        {
            base.OnActivate();
            AddBrandingPanel();
            HasBeenActivated = true;
            this.Cancellable = false;
            this.ShowInfoPanel = false;

            //get title, description and version
            string path = Path.Combine(GetBasePath(), "SPALM.SPSF.xml");
            if (File.Exists(path))
            {
                XmlDocument guidanceDoc = new XmlDocument();
                guidanceDoc.Load(path);

                XmlNamespaceManager nsmgr = new XmlNamespaceManager(guidanceDoc.NameTable);
                nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/pag/gax-core");
                nsmgr.AddNamespace("spsf", "http://spsf.codeplex.com");
                nsmgr.AddNamespace("wiz", "http://schemas.microsoft.com/pag/gax-wizards");

                XmlNode rootNode = guidanceDoc.SelectSingleNode("/ns:GuidancePackage", nsmgr);
                if (rootNode != null)
                {
                    label_title.Text = rootNode.Attributes["Caption"].Value.ToString();
                    label_description.Text = rootNode.Attributes["Description"].Value.ToString();
                    label_version.Text = rootNode.Attributes["Version"].Value.ToString();
                }
            }

            //get fileversion of assembly
            label_fileversion.Text = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

            //TODO: get contributors from Authors.xml
            return true;
        }
开发者ID:sunday-out,项目名称:SharePoint-Software-Factory,代码行数:35,代码来源:AboutPage.cs


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