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

<small id='0cxEe'></small><noframes id='0cxEe'>

      <tfoot id='0cxEe'></tfoot>
    1. 在 Java 中使用命名空间创建 XML 文档

      Creating an XML document using namespaces in Java(在 Java 中使用命名空间创建 XML 文档)
      • <small id='OtEGv'></small><noframes id='OtEGv'>

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

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

              <tbody id='OtEGv'></tbody>
              • <legend id='OtEGv'><style id='OtEGv'><dir id='OtEGv'><q id='OtEGv'></q></dir></style></legend>

                本文介绍了在 Java 中使用命名空间创建 XML 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在寻找可以构建使用名称空间的 XML 文档的示例 Java 代码.我似乎无法使用我的常规最喜欢的工具找到任何东西,所以希望有人能帮助我.p>

                I am looking for example Java code that can construct an XML document that uses namespaces. I cannot seem to find anything using my normal favourite tool so was hoping someone may be able to help me out.

                推荐答案

                我不确定,你想做什么,但我使用 jdom 用于我的大多数 xml 问题,它支持命名空间(当然).

                I am not sure, what you trying to do, but I use jdom for most of my xml-issues and it supports namespaces (of course).

                代码:

                Document doc = new Document();
                Namespace sNS = Namespace.getNamespace("someNS", "someNamespace");
                Element element = new Element("SomeElement", sNS);
                element.setAttribute("someKey", "someValue", Namespace.getNamespace("someONS", "someOtherNamespace"));
                Element element2 = new Element("SomeElement", Namespace.getNamespace("someNS", "someNamespace"));
                element2.setAttribute("someKey", "someValue", sNS);
                element.addContent(element2);
                doc.addContent(element);
                

                生成以下 xml:

                <?xml version="1.0" encoding="UTF-8"?>
                 <someNS:SomeElement xmlns:someNS="someNamespace" xmlns:someONS="someOtherNamespace"  someONS:someKey="someValue">
                  <someNS:SomeElement someNS:someKey="someValue" />
                 </someNS:SomeElement>
                

                其中应该包含您需要的一切.希望对您有所帮助.

                Which should contain everything you need. Hope that helps.

                这篇关于在 Java 中使用命名空间创建 XML 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                How can I detect integer overflow on 32 bits int?(如何检测 32 位 int 上的整数溢出?)
                Local variables before return statements, does it matter?(return 语句之前的局部变量,这有关系吗?)
                How to convert Integer to int?(如何将整数转换为整数?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在给定范围内创建一个随机打乱数字的 int 数组)
                Inconsistent behavior on java#39;s ==(java的行为不一致==)
                Why is Java able to store 0xff000000 as an int?(为什么 Java 能够将 0xff000000 存储为 int?)
                <tfoot id='QnEMJ'></tfoot>

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

                      <tbody id='QnEMJ'></tbody>

                          <bdo id='QnEMJ'></bdo><ul id='QnEMJ'></ul>
                        • <small id='QnEMJ'></small><noframes id='QnEMJ'>

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