I am facing with another problem.
I have kind of XML file with example code:
<case classname="perf" name="device">
<Type>GET</Type>
<Name>xxx</Name>
<Request>Something</Request>
</case>
<case2 name="device_n>
<Type>GET</Type>
<Name>yyy</Name>
<Request>Something</Request>
</case2>
<case...n>
...
</case...n>
How can I replace xxx to be named 'device' and yyy in case2 to be device_n?
I think something like that could be OK, but don't know how to write it:
with open('some_xml.xml') as parsed:
if line in parsed.readlines.startswith("name="):
line.replace('', "name=... #what's now?
This should be somekind of iterator because I have a lot of cases.
readlinesis a function which neads().readlines()gives list and list doesn't havestartswith(). String has functionstartswith()butname=is not at the beginning of the line so checkingstartswith("name=")makes no sense. Other problem is thatxxxis in diffferent line then "name=" so you can't use replace in the sameline.