I am using Bueatiful Soup with the XML parser
soup = BeautifulSoup(open("/root/sandbox/garbage/example_jmx.jmx"), "xml")
This keeps the attributes upper\lower case as in the parsed file. (FYI, Using the "lxml" parser results in all the attributes being saved as lower case.)
But I am left with 2 other problems.
e.g.for #1
<TestPlan enabled="true" guiclass="TestPlanGui" testclass="TestPlan">
turns to
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" enabled="true">
How can I keep the original attributes order and lines indentation?
dict object, dict is unordered object.children parent to show the relationship of tag. If you want to keep all the indentation and order of attribute, you should open the file directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With