我有一個sample.xml中文件below..I需要掃描的項目「裁判後的「修改」標籤「內核/ MSM」和 打印字/heads"..i下面有一個sample.xml文件和xml輸出嗎?我可以稍後找出python部分,任何人都可以提供關於如何完成此操作的輸入?閱讀修訂標記一個XML文件,指定項目
輸入: -
Assume there is a variable project like below
project='kernel/msm'
sample.xml
<?xml version="1.0" encoding="utf-8"?>
<project name="platform/vendor/google/proprietary/code"
path="vendor/widevine"
revision="refs/heads/ab_mr"
x-grease-customer="none"
x-quic-dist="none"
x-ship="none" />
<!-- test Projects -->
<project name="kernel/msm"
path="kernel"
revision="refs/heads/msm-3.4"
x-grease-customer="none"
x-quic-dist="la"
x-ship="oss" />
......
EXPECTED OUTPUT:-
msm-3.4
Sample code:-
project='kernel/msm'
#open xml file
with open('./test.xml', 'r') as f:
#get the branch and project
for line in project :
if line in 'revision':
branch = line.split('/')[-1]
print branch
感謝
可以附加你試着使用一些示例代碼,也許說爲什麼,這不是爲你工作?這裏沒有太多可以繼續。 – 2013-07-09 04:57:29
@LegoStormtroopr - I與樣品代碼 – user2125827
使用模塊特殊的XML如'xml.etree.ElementTree'更新。 – zhangyangyu