Here is my dilemma:
I have an XML, where I want to insert animation_sequence,however, instead the code adds animation_sequnce/> with an opening angle bracket, I can add all other elements but that one. Why is that? I tried adding the XML here but it wouldn’t render. Here is my code:
Element state = testDoc.createElement("state");
state.setTextContent(element);
Element animationState = testDoc.createElement("animation_state");
Element sequence = testDoc.createElement("animation_sequence");
testDoc.getElementsByTagName("animations_list").item(0).appendChild(animationState).appendChild(state);
testDoc.getElementsByTagName("animation_state").item(testDoc.getElementsByTagName("state").getLength() - 1).appendChild(sequence);
The code you have shown us creates nodes in a tree. It doesn’t append any angle brackets to anything. Angle brackets only appear when you serialize the tree (convert it to lexical XML). Generally the system takes care of how to serialize the XML, and you don’t need to worry when it chooses between different ways of serializing it because when the XML is parsed the differences won’t matter.
Now it could be that the “/>” is a symptom that the tree you have built isn’t the tree that you intended to build, but that’s a different matter.