Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的XML输出不是我想要的_Xml - Fatal编程技术网

我的XML输出不是我想要的

我的XML输出不是我想要的,xml,Xml,附件是两个屏幕截图和我的代码。我正在尝试将动画_序列作为结束和结束括号,我已经尽了最大努力,但现在我寻求您的帮助。这是我的尝试,我决定这样做,但现在我的状态,在“雅虎”出现为“雅虎”,我知道它可能与动画序列的内容有关(虽然我不明白这是如何给我的状态内容添加空格的。我的问题是,我只想让动画序列有结束括号和结束括号。我通过在if语句中寻找两个额外空格来解决问题,但我觉得这是一种可悲的方法,有点像接受失败。 我附加的第二个图像是我希望实现的,而不是在我的状态中添加额外的“”。如果没有我下面的代码(特定

附件是两个屏幕截图和我的代码。我正在尝试将动画_序列作为结束和结束括号,我已经尽了最大努力,但现在我寻求您的帮助。这是我的尝试,我决定这样做,但现在我的状态,在“雅虎”出现为“雅虎”,我知道它可能与动画序列的内容有关(虽然我不明白这是如何给我的状态内容添加空格的。我的问题是,我只想让动画序列有结束括号和结束括号。我通过在if语句中寻找两个额外空格来解决问题,但我觉得这是一种可悲的方法,有点像接受失败。 我附加的第二个图像是我希望实现的,而不是在我的状态中添加额外的“”。如果没有我下面的代码(特定的设置文本内容部分),它将生成图像一。就在我认为我解决了它的时候,这两个空格正在扼杀我。如果你需要任何额外的代码,请告诉我。我需要你的帮助

Element animationState = testDoc.createElement("animation_state");
        Element sequence = testDoc.createElement("animation_sequence");
        sequence.setTextContent(" ");
        sequence.appendChild(testDoc.createTextNode(" "));
testDoc.getElementsByTagName("animations_list").item(0).appendChild(animationState).appendChild(state);
        testDoc.getElementsByTagName("animation_state").item(testDoc.getElementsByTagName("state").getLength() - 1).appendChild(sequence);


   for(int i = 0; i<testDoc.getElementsByTagName("animation_state").getLength(); i++)
   {
       if(  testDoc.getElementsByTagName("animation_state").item(i).getTextContent().
            equals(Poseur.getPoseur().getAnimatedSpriteViewer().getSpriteStateComboBox().
            getSelectedItem().toString())||(testDoc.getElementsByTagName("animation_state").item(i).getTextContent()).equals(Poseur.getPoseur().getAnimatedSpriteViewer().getSpriteStateComboBox().getSelectedItem().toString()+"  "))
       {
           testDoc.getElementsByTagName("animation_sequence").item(i).appendChild(poseImage);
       }
   }
Element animationState=testDoc.createElement(“动画状态”);
元素序列=testDoc.createElement(“动画序列”);
sequence.setTextContent(“”);
sequence.appendChild(testDoc.createTextNode(“”);
testDoc.getElementsByTagName(“动画列表”).item(0).appendChild(动画状态).appendChild(状态);
testDoc.getElementsByTagName(“动画状态”).item(testDoc.getElementsByTagName(“状态”).getLength()-1)、appendChild(序列);

对于(int i=0;i在创建
动画序列
节点时,在Java中,似乎是在抽象树结构中工作。此时,没有打开或关闭标记,只有节点

“标记”(开始和结束)的存在是XML文档序列化的一个方面,即如何将其转换为文本形式进行输出。就标准而言,序列化
是无法区分的,因此允许序列化程序编写其中任何一个


一些序列化程序将允许您指定如何以速记形式写出空节点(尾随
/
)或者作为开始/结束标记对。您需要研究特定的XML库,并确定序列化程序是否提供了这样的选项。

我使用的是true DOM API,我尝试将其保留为wag,但当我附加到动画序列时,它没有被添加到它的右括号中。此外,当设置内容时,为什么我有两个e我以前的元素内容中的xtra空格,即状态