elementProp.setTextContent(null); elementProp.appendChild(collectionProp); } private static void appendElementProp(Document document, Node parentNode, String contextType, String contextPostData) { // eleme prop Node elementProp = document.createElement("elementProp"); NamedNodeMap attributes = elementProp.getAttributes(); attributes.setNamedItem(createAttribute(document, "name", "HTTPsampler.Arguments")); attributes.setNamedItem(createAttribute(document, "elementType", "Arguments")); attributes.setNamedItem(createAttribute(document, "guiclass", "HTTPArgumentsPanel")); attributes.setNamedItem(createAttribute(document, "testclass", "Arguments")); attributes.setNamedItem(createAttribute(document, "testname", "User Defined Variables")); attributes.setNamedItem(createAttribute(document, "enabled", "true")); appendCollectionProp(document, elementProp, contextType, contextPostData); //parentNode.setTextContent(null); parentNode.appendChild(elementProp); } private static void appendCollectionProp(Document document, Node elementProp, String contextType, String contextPostData) { // collection append in prop String argumentValue = null; if(contextType.equals(FrameworkConstants.POST)) { argumentValue = contextPostData; } Node collectionProp = document.createElement("collectionProp"); NamedNodeMap attributes = collectionProp.getAttributes(); attributes.setNamedItem(createAttribute(document, "name", "Arguments.arguments")); Node subElementProp = document.createElement("elementProp"); NamedNodeMap subElementAttributes = subElementProp.getAttributes(); subElementAttributes.setNamedItem(createAttribute(document, "name", "")); subElementAttributes.setNamedItem(createAttribute(document, "elementType", "HTTPArgument")); collectionProp.appendChild(subElementProp); appendTypeProp(document, subElementProp, "boolProp", "HTTPArgument.always_encode", "false"); appendTypeProp(document, subElementProp, "stringProp", "Argument.value", argumentValue); appendTypeProp(document, subElementProp, "stringProp", "Argument.metadata", "="); appendTypeProp(document, subElementProp, "boolProp", "HTTPArgument.use_equals", "true"); elementProp.setTextContent(null); elementProp.appendChild(collectionProp); } private static void appendTypeProp(Document document, Node parentProp, String tag, String nameAttr, String textContent) { Node typeProp = document.createElement(tag); NamedNodeMap attributes = typeProp.getAttributes(); attributes.setNamedItem(createAttribute(document, "name", nameAttr)); typeProp.setTextContent(textContent); parentProp.appendChild(typeProp); } private static Attr createAttribute(Document document, String attrName, String attrValue) { Attr attr = document.createAttribute(attrName); attr.setValue(attrValue); return attr; } private static void saveDocument(File file, Document doc) throws Exception {