gpt4 book ai didi

java - 放置 xmlns :xsi into my schema using java

转载 作者:行者123 更新时间:2023-12-02 03:59:40 25 4
gpt4 key购买 nike

我有以下代码

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element rootElement = document.createElementNS("http://www.w3.org/2001/XMLSchema-instance\", xmlns=\"http://www.europe.xsd","EMOTable1");//create the rootelement
document.appendChild(rootElement);//append the root element to the doc

问题是当我运行代码时,我在 EMOtable1 之后没有得到以下创建的 xmlns:xsi ,例如:

<EMOTable1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.europe.xsd">

我不太清楚 xmlns:xsi 的含义,那么我该如何插入它?

我正在使用 javax 库

这是目前所写的内容

<EMOTABLE1 xmlns="http://www.w3.org/2001/XMLSchema-instance&quot;xmlns=&quot;http://www.europe.xsd">

@wero

最佳答案

首先创建命名空间元素:

Element rootElement = doc.createElementNS("http://www.europe.xsd", "EMOTable1");

然后添加第二个命名空间声明

rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

关于java - 放置 xmlns :xsi into my schema using java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35072879/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com