我有一个如下的sample.xml文件..我需要扫描项目“kernel/msm”的“revision”标签并在“refs/heads”之后打印这个词..我下面有一个sample.xml文件和xml输出?我以后可以弄清楚python部分,任何人都可以提供如何做到这一点的输入吗?
输入:-
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
谢谢