You may know that the jmx file is an xml file type and has a node structure on node. Using any XML apis jmx files can be created programmatically. My suggestion is to create a complete test plan in jmeter with all the basic test elements, such as Samplers, Listeners, Pre and Post, and save the jmx file, and then collect new XML files based on this jmx structure as follows
<jmeterTestPlan version="1.2" properties="2.4" jmeter="2.9">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Regular Expression Extractor" enabled="true">
<stringProp name="RegexExtractor.useHeaders">false</stringProp>
<stringProp name="RegexExtractor.refname">REF</stringProp>
<stringProp name="RegexExtractor.regex">(.*)</stringProp>
<stringProp name="RegexExtractor.template">$1$</stringProp>
</RegexExtractor>
</hashTree>
</hashTree>
</jmeterTestPlan>
API javax.xml XML (. ), . , , - -, . #.
.