Python xbmc中频图像显示语句
我有我用xml编写的图像列表,我可以在xbmc上运行它们 以下是xml中的图像列表:Python xbmc中频图像显示语句,python,python-2.7,xbmc,Python,Python 2.7,Xbmc,我有我用xml编写的图像列表,我可以在xbmc上运行它们 以下是xml中的图像列表: <?xml version="1.0" encoding="utf-8"?> <window type="dialog"> <allowoverlay>no</allowoverlay> <coordinates> <system>1</system> <posx>0&
<?xml version="1.0" encoding="utf-8"?>
<window type="dialog">
<allowoverlay>no</allowoverlay>
<coordinates>
<system>1</system>
<posx>0</posx>
<posy>0</posy>
</coordinates>
<controls>
<control type="image" id="1">
<description>Image1</description>
<posx>307</posx>
<posy>7</posy>
<width>164</width>
<height>102</height>
<visible>true</visible>
<texturefocus>image1_blue.jpg</texturefocus>
<texturenofocus>image1_yellow.jpg</texturenofocus>
<onup>2</onup>
<ondown>3</ondown>
<onleft>1</onleft>
<onright>1</onright>
</control>
<control type="image" id="2">
<description>Image2</description>
<posx>471</posx>
<posy>7</posy>
<width>201</width>
<height>102</height>
<visible>true</visible>
<texturefocus>image2_yellow.jpg</texturefocus>
<texturenofocus>image2_blue.jpg</texturenofocus>
<onup>2</onup>
<ondown>3</ondown>
<onleft>1</onleft>
<onright>1</onright>
</control>
<control type="image" id="4">
<description>Image3</description>
<posx>671</posx>
<posy>7</posy>
<width>177</width>
<height>102</height>
<visible>true</visible>
<texturefocus>image3_yellow.jpg</texturefocus>
<texturenofocus>image3_blue.jpg</texturenofocus>
<onup>2</onup>
<ondown>3</ondown>
<onleft>1</onleft>
<onright>1</onright>
</control>
<control type="image" id="6">
<description>image4</description>
<posx>848</posx>
<posy>7</posy>
<width>176</width>
<height>102</height>
<visible>true</visible>
<texturefocus>image4_yellow.jpg</texturefocus>
<texturenofocus>image4_blue.jpg</texturenofocus>
<onup>2</onup>
<ondown>3</ondown>
<onleft>1</onleft>
<onright>1</onright>
</control>
</controls>
</window>
不
1.
0
0
图1
307
7.
164
102
真的
图1_blue.jpg
image1_yellow.jpg
2.
3.
1.
1.
图2
471
7.
201
102
真的
图2_yellow.jpg
图2_blue.jpg
2.
3.
1.
1.
图3
671
7.
177
102
真的
image3_yellow.jpg
图3_blue.jpg
2.
3.
1.
1.
图4
848
7.
176
102
真的
image4_yellow.jpg
image4_blue.jpg
2.
3.
1.
1.
我想知道如何用python为xbmc编写if语句,如果图像包含id,那么我想知道如何使用id更改图像?python附带
xml
模块,该模块具有有用的ElementTree
,可以满足您的需要
下面是一个如何使用它的示例:
import xml.etree.ElementTree as ET
filename = 'name_of_the_xml_file.xml'
tree = ET.parse(filename)
root = tree.getroot()
controls = root.find('controls')
for control in controls.findall('control'):
# Here are the image filenames, focus and nofocus.
focus = control.find('texturefocus').text
nofocus = control.find('texturenofocus').text
print('texturefocus={0}, texturenofocus={1}'.format(focus, nofocus))
进一步阅读:。询问代码的问题必须证明对所解决问题的理解程度最低。包括尝试过的解决方案、它们不起作用的原因以及预期结果。另请参见:。您需要一个XML解析器来获取字符串(文件路径),然后可以使用示例检查文件是否存在。@Keeler是的,这就是我试图通过XML解析器获取字符串的方法。很抱歉,我查看了您发送的链接,其中有很多解析器用于获取字符串,我不知道应该使用哪一个用于XML解析器。你可以发布一个我应该使用的XML解析器示例吗?@Keeler你能告诉我在你已经发送的链接中我应该使用哪个XML解析器吗?@Keeler谢谢你。我有四个在xbmc中运行的图像。我想为if语句创建,如果图像存在,返回true,然后做些什么?例如,
如果os.path.exists('Q:\\resources\skins\Default\media\tvguide\u yellow.png')==True:
我试图使用它,但它不起作用。有什么想法吗?