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

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

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

    2. 带有冒号的 xml 元素名称

      时间:2023-09-16
      • <tfoot id='NYyin'></tfoot>
            <tbody id='NYyin'></tbody>

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

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

              • <bdo id='NYyin'></bdo><ul id='NYyin'></ul>
                <legend id='NYyin'><style id='NYyin'><dir id='NYyin'><q id='NYyin'></q></dir></style></legend>
                本文介绍了带有冒号的 xml 元素名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用第 3 方 xml api.他们已经定义了一个类似于下面的所需的 xml 结构.

                I'm working against a 3rd party xml api. They have defined a required xml structure similar to the following.

                <ns1:E xmlns:ns1="schema">
                <ns1:B>
                    <ns2:S>
                        <ns2:V>
                            <ns2:Bl />
                        </ns2:V>
                    </ns2:S>
                </ns1:B>
                </ns1:E>
                

                有一个 SQL 表,其中包含我需要放入此 xml 格式的信息.我有一个 LINQ to SQL 适配器来获取数据,我正在使用 System.Xml 创建一个 XML 文档.

                There is a SQL table with the information that I need to put into this xml format. I have a LINQ to SQL adapter to get the data and I'm using a System.Xml to create an XML document.

                XmlDocument.CreateElement("ns1:E"); etc
                

                只要我从元素名称中删除冒号,它就可以正常工作.对于冒号,只有冒号的右侧位于元素名称中.我知道冒号是一个禁忌,但我无法控制 3rd 方 api 所指示的内容.

                This works fine as long as I remove the colons from the element names. With the colons, only the right hand side of the colon is in the element name. I know colons are a no-no but I don't have any control over what the 3rd party api is dictating.

                我有哪些解决方法?是否有任何有用的方法可以将冒号强制输入元素名称?我不必使用 XMLDocument 但不确定还有什么其他方法可以让我到达那里.

                What are my options for getting around this? Are there any useful ways of forcing the colons into the element names? I don't have to use XMLDocument but not sure what other method will get me there.

                更新:我意识到 <ns1: 指的是命名空间.是的,有 2 个.在写出 XML 时,如果我说,我可以让它工作 -

                UPDATE: I realize that the <ns1: refers to a namespace. And yes, there are 2. When writing out the XML, I can make it work if I say -

                 XmlDocument.CreateElement("ns1:E", "http://schema");
                

                然而,这个的 XML 输出是

                However, the XML output of this is

                <ns1:E xmlns:ns1="http://schema">
                

                如果我只是说 XmlDocument.CreateElement("ns1:E"); 没有 uri,那么输出只是 <E>.我不希望输出具有架构引用,但我确实需要具有前缀.我想要达到的结果就是<ns1:E>.两个命名空间都在顶部声明,我认为这意味着我必须在每个节点上声明它们.

                If I just say XmlDocument.CreateElement("ns1:E"); with no uri, then the output is just <E>. I don't want the output to have the schema reference but I do need to have the prefix. The result I want to achieve is simply <ns1:E>. Both namspaces are declared at the top which I would think would mean I would have to declare them at every node.

                推荐答案

                好的,就到这里.

                XmlDocument.CreateElement("prefix", "name", "uri");
                

                如果对其他人有帮助,请在此处参考:http://msdn.microsoft.com/en-us/library/c22k3d47.aspx 1

                reference here if it helps someone else: http://msdn.microsoft.com/en-us/library/c22k3d47.aspx 1

                这篇关于带有冒号的 xml 元素名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:整个命名空间的“SuppressMessage" 下一篇:.NET String.Format() 为数字添加千位逗号

                相关文章

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

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

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

                    <legend id='u5LS9'><style id='u5LS9'><dir id='u5LS9'><q id='u5LS9'></q></dir></style></legend>