-3

I need to generate the below xml using python

How do i generate? can some one please advise.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="12" preserve-order="true" >
    <test name="MY">
        <classes>
            <class name="PIB_MY.Login" />
            <class name="PIB_MY.FundTransfer" />
            <class name="PIB_MY.BillPayment" />
            <class name="PIB_MY.AddManageDeletePayee" />
            <class name="PIB_MY.SmartClick" />
            <class name="PIB_MY.Logout" />
        </classes>
    </test>
</suite> 
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
garlapak
  • 2,309
  • 3
  • 14
  • 12

1 Answers1

0

Quite simply:

xml = """
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="12" preserve-order="true" >
    <test name="MY">
        <classes>
            <class name="PIB_MY.Login" />
            <class name="PIB_MY.FundTransfer" />
            <class name="PIB_MY.BillPayment" />
            <class name="PIB_MY.AddManageDeletePayee" />
            <class name="PIB_MY.SmartClick" />
            <class name="PIB_MY.Logout" />
        </classes>
    </test>
</suite> 
"""

print(xml)

Voilà, problem solved.

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
  • I need to generate from the elements. Thanks – garlapak Oct 05 '18 at 08:15
  • @garlapak sorry but that's nowhere in your question, so my answer is technically perfect. If you expect any useful answer (instead of downvotes, close votes and obviously ironic answers like this one), then post a real question. – bruno desthuilliers Oct 05 '18 at 08:18