1. <tfoot id='cK6TL'></tfoot><legend id='cK6TL'><style id='cK6TL'><dir id='cK6TL'><q id='cK6TL'></q></dir></style></legend>
          <bdo id='cK6TL'></bdo><ul id='cK6TL'></ul>

        <small id='cK6TL'></small><noframes id='cK6TL'>

        <i id='cK6TL'><tr id='cK6TL'><dt id='cK6TL'><q id='cK6TL'><span id='cK6TL'><b id='cK6TL'><form id='cK6TL'><ins id='cK6TL'></ins><ul id='cK6TL'></ul><sub id='cK6TL'></sub></form><legend id='cK6TL'></legend><bdo id='cK6TL'><pre id='cK6TL'><center id='cK6TL'></center></pre></bdo></b><th id='cK6TL'></th></span></q></dt></tr></i><div id='cK6TL'><tfoot id='cK6TL'></tfoot><dl id='cK6TL'><fieldset id='cK6TL'></fieldset></dl></div>
      2. 如何删除命名空间前缀.(C#)

        How to remove namespace prefix. (C#)(如何删除命名空间前缀.(C#))

              <bdo id='Z70k1'></bdo><ul id='Z70k1'></ul>
              • <legend id='Z70k1'><style id='Z70k1'><dir id='Z70k1'><q id='Z70k1'></q></dir></style></legend>

                  <tbody id='Z70k1'></tbody>
                1. <tfoot id='Z70k1'></tfoot>
                  <i id='Z70k1'><tr id='Z70k1'><dt id='Z70k1'><q id='Z70k1'><span id='Z70k1'><b id='Z70k1'><form id='Z70k1'><ins id='Z70k1'></ins><ul id='Z70k1'></ul><sub id='Z70k1'></sub></form><legend id='Z70k1'></legend><bdo id='Z70k1'><pre id='Z70k1'><center id='Z70k1'></center></pre></bdo></b><th id='Z70k1'></th></span></q></dt></tr></i><div id='Z70k1'><tfoot id='Z70k1'></tfoot><dl id='Z70k1'><fieldset id='Z70k1'></fieldset></dl></div>

                  <small id='Z70k1'></small><noframes id='Z70k1'>

                  本文介绍了如何删除命名空间前缀.(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 XElement,它是由如下所示的转换产生的.

                  I have an XElement, resulting from a transform that looks like the following.

                  <src:Person xmlns:src="http://www.palantir.za">
                    <src:Name>Jenifer Harvey</src:Name>
                    <src:BirthDate>1969-11-13</src:BirthDate>
                    <src:IdentityNumber>6906678550017</src:IdentityNumber>
                    <src:Sex>Male</src:Sex>
                  </src:Person> 
                  

                  我想将此 XElement 转换为一个新的 XElement,该 XElement 具有src"作为默认命名空间,而不是上面的命名"命名空间.

                  I would like to transform this XElement into a new XElement that has 'src' as a default namespace rather than a 'named' namespace as above.

                  我意识到它们可能在语义上是相同的,我只是想保持存储内容的一致性.

                  I realise they are probably semantically identical, I just want to maintain consistency in what is being stored.

                  我想要以下.

                  <Person xmlns="http://www.palantir.za">
                          <Name>Jenifer Harvey</Name>
                          <BirthDate>1969-11-13</BirthDate>
                          <IdentityNumber>6906678550017</IdentityNumber>
                          <Sex>Male</Sex>
                  </Person> 
                  

                  谢谢

                  问候

                  克雷格.

                  推荐答案

                  只需删除 xmlns:src 属性并添加一个新的 xmlns 属性:

                  Simply remove the xmlns:src attribute and add a new xmlns attribute:

                  XDocument xdoc = XDocument.Parse(
                          "<src:Person xmlns:src="http://www.palantir.za">" +
                          "  <src:Name>Jenifer Harvey</src:Name>" +
                          "  <src:BirthDate>1969-11-13</src:BirthDate>" +
                          "  <src:IdentityNumber>6906678550017</src:IdentityNumber>" +
                          "  <src:Sex>Male</src:Sex>" +
                          "</src:Person>");
                  
                  xdoc.Root.Add(new XAttribute("xmlns", "http://www.palantir.za"));
                  xdoc.Root.Attributes(XNamespace.Xmlns + "scr").Remove();
                  

                  这篇关于如何删除命名空间前缀.(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)
                2. <legend id='rnYWt'><style id='rnYWt'><dir id='rnYWt'><q id='rnYWt'></q></dir></style></legend>
                  <tfoot id='rnYWt'></tfoot>

                        <bdo id='rnYWt'></bdo><ul id='rnYWt'></ul>

                            <small id='rnYWt'></small><noframes id='rnYWt'>

                              <tbody id='rnYWt'></tbody>
                          1. <i id='rnYWt'><tr id='rnYWt'><dt id='rnYWt'><q id='rnYWt'><span id='rnYWt'><b id='rnYWt'><form id='rnYWt'><ins id='rnYWt'></ins><ul id='rnYWt'></ul><sub id='rnYWt'></sub></form><legend id='rnYWt'></legend><bdo id='rnYWt'><pre id='rnYWt'><center id='rnYWt'></center></pre></bdo></b><th id='rnYWt'></th></span></q></dt></tr></i><div id='rnYWt'><tfoot id='rnYWt'></tfoot><dl id='rnYWt'><fieldset id='rnYWt'></fieldset></dl></div>