So, I'm trying to parse the xml and taking a value on the commandline by python. Here's the code that pretty much explains itself.
APPLY_DIR=$(python -c 'from xml.dom import minidom;xmldoc=minidom.parse("args.xml");itemlist=xmldoc.getElementsByTagName("item");print str(itemlist[6].attributes["patchApplyDir"])')
REVERT_DIR=$(python -c 'from xml.dom import minidom;xmldoc=minidom.parse("args.xml");itemlist=xmldoc.getElementsByTagName("item");print str(itemlist[7].attributes["patchRevertDir"])')
echo $APPLY_DIR
echo $REVERT_DIR
The problem is that it returns the following output:
<xml.dom.minidom.Attr instance at 0x7fba97db07e8>
<xml.dom.minidom.Attr instance at 0x7fb820e80998>
Here's my xml file args.xml
<data>
<args>
<item svn_repo = "https://ntil-svn-u1:18080/svn/HSAN_SW_DEVELOPMENT/HSAN-SW-DEV/Project/Engineering/Code/HSAN_INTEGRATION/HSAN_MERGE/Tags/HSAN_ST_RELEASE_16_12_2016_"></item>
<item svn_revision = "991/"></item>
<item checkout_path = "/root/Neeraj/GGG"></item>
<item pre_build = "Default1"></item>
<item build_script = "Default1"></item>
<item svnCheckoutPath = "/root/Neeraj/GGG"></item>
<item patchApplyDir = "./GGG/Apply"></item>
<item patchRevertDir = "./GGG/Revert"></item>
<item APPLY_DIR="./Apply"></item>
<item REVERT_DIR="./Revert"></item>
<item VERSION_MINOR="100"></item>
<item VERSION_INTERNAL="200"></item>
<item INPUT="300"></item>
</args>
</data>
Please let me know what am I doing wrong here? Also, I don't want to make a separate file to write python code, I have to do it in the command only. Thanks.