Torewin
Torewin

Reputation: 64

JAVA XMLOutPuter changing values of other nodes in XML document

I am using the below method to produce an XML document using getFile() to get the same file as my SAXBuilder.

SAXBuilder reader = new SAXBuilder();
Document document = reader.build(new File(file)); //file example: Desktop/test.camproj (which is an XML document)

When I write the file I use the below code. I only change one value in the XML document (which works), but when I open up this video (this xml file is a video file) all the values of all nodes of type Callout have been changed to their defaults. Is this the correct way of creating the file or am I doing something wrong? If I don't open the video and open the file in Notepad nothing except the node I change was altered.

XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat());
FileOutputStream output = new FileOutputStream(getFile());
xmlOutput.output(document, output);
document.detachRootElement();
output.close();

My change to the xml node (I am using /n/r to represent line breaks in XML):

newText = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 Open Sans"
                + ";}}\n\r{\\colortbl ;\\red0\\green0\\blue0;}\n\r\\viewkind4\\uc1\\pard\\qc\\cf1\\f0\\fs36 " + newText + "\\par\n\r}\n\r;";

        document.getRootElement().getChild("CSMLData").getChild("GoProject").getChild("Project")
        .getChild("Timeline").getChild("GenericMixer").getChild("Tracks").getChildren().get(index2).getChild("Medias").getChildren().get(index)
        .getChild("Attributes").getChild("Attribute").getChild("VectorNode").getChild("StringParameters")
        .getChildren().get(3).getChild("Keyframes").getChild("Keyframe").setAttribute("value", newText);

Upvotes: 0

Views: 38

Answers (0)

Related Questions