You need mostly XmlSuite and XmlTest classes, once you instantiate the classes and populate them with the required configuration - you will be able to call XmlSuite.toXml() function and store generated suite into the file of your choice.
Example code:
XmlSuite suite = new XmlSuite();
suite.setName("TestNG XML created from Java Code");
suite.setParallel(XmlSuite.ParallelMode.TESTS);
suite.setThreadCount(10);
XmlTest xmlTest1 = new XmlTest(suite);
xmlTest1.setName("My first test");
xmlTest1.addParameter("foo", "bar");
XmlTest xmlTest2 = new XmlTest(suite);
xmlTest2.setName("My second test");
xmlTest2.addParameter("baz", "qux");
System.out.println(suite.toXml());
But testng.xml already does perfect parallel, I don’t want to deal with hub and nodes…
I just want help to be able to edit the testng.xml moment before running it and to edit the device amount/test ls amount…