I'm trying to edit an existing xml using Iron python but nothing works.
My Xml contains some data regarding the screens connected to my computer, and I want to change the resolution every time . Example :
<monitor id="16843008" adapterHigh="0" adapterLow="31682">
<name>IBM L190p</name>
<!--source: the origin of the video signal-->
<source id="0">
<name>\\.\DISPLAY1</name>
<path>\\?\PCI#VEN_8086&DEV_0126&SUBSYS_21CE17AA&REV_09#3&e89b380&0&10#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}</path>
</source>
<size width="1280" height="1024"/>
<position left="1280" top="0"/>
<!--8bpp-->
<!--16bpp-->
<!--24bpp-->
<!--32bpp-->
<!--Non-GDI-->
<color value="32bpp"/>
<!--Identity-->
<!--90-degreesCW-->
<!--180-degreesCW-->
<!--270-degreesCW-->
<rotation value="Identity"/>
<!--Identity-->
<!--Centered-->
<!--Stretched-->
<!--Aspect Ratio Centered Max-->
<!--Custom-->
<!--Preferred-->
<scaling value="Identity"/>
<!--A value of 0/0 represents the optimal refresh rate. Scan-line-order must be Unspecified.-->
<refresh numerator="108000000" denominator="1799408"/>
<!--Unspecified-->
<!--Progressive-->
<!--Interlaced (upper field first)-->
<!--Interlaced (lower field first)-->
<scanlineorder value="Progressive"/>
</monitor>
<!--monitor:-->
<!--The id attribute must be specified.-->
<monitor id="54733568" adapterHigh="0" adapterLow="31682">
<name>LEN L192p</name>
<!--source: the origin of the video signal-->
<source id="1">
<name>\\.\DISPLAY2</name>
<path>\\?\PCI#VEN_8086&DEV_0126&SUBSYS_21CE17AA&REV_09#3&e89b380&0&10#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}</path>
</source>
<size width="1280" height="1024"/>
<position left="0" top="0"/>
<!--8bpp-->
<!--16bpp-->
As you can see, this xml contains "width" and "height" that I want them to be changed, by constructing a function that the input will be monitor id, and the new resolution.
I wanted to start with finding the needed node but even that didn't work :
import clr
clr.AddReference('System.Xml')
from System.Xml import *
XMLDoc=XmlDocument()
XMLDoc.Load(r"C:\Users\myuser\Desktop\ThreeMonitors.xml")
t= XMLDoc.GetElementById("16843008") ->> Returns "None"
Can anyone advise please? How to move ahead and what am I doing wrong?
thanks!!
No comments:
Post a Comment