I am trying to use python to edit .plist files, which are in XML format. In this example, I want to modify the IP address.
<dict>
<key>ProgramArguments</key>
<array>
<string>/Applications/ExD2017/render/bin/renderqueue</string>
<string>-h</string>
<string>127.0.0.1</string>
</array>
</dict>
In this case, I can get the value by using root[1][2].text
, but this will break if the argument order in the XML changes. So I need to find it by specifying the tag following the tag named string whose value is -h
. How can I find the index of the string whose value is -h
? It should be a nested number like root[x][x]
.