Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6736673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:09:28+00:00 2026-05-26T11:09:28+00:00

I have a XML and a code. But I can’t figure out how to

  • 0

I have a XML and a code. But I can’t figure out how to do the part.

XML:

<settings>
<plugin id="1" name="Send Mail" execute="func/sendmail.py">
    <param name="towhere" value="To Where?" />
    <param name="mailsub" value="Mail Subject" />
    <param name="mailcont" value="Mail Content" />
    <param name="senderid" value="xxxx@gmail.com" />
    <param name="senderpw" value="xxxx" />
</plugin>
<plugin id="2" name="Open Tar" execute="func/taropen.py">
    <param name="tarname" value="Tar file name" />
    <param name="tarloc" value="Tar location" />
    <param name="tardest" value="Tar destination" />
</plugin>
<plugin id="3" name="Server Reboot" execute="func/reboot.py">
    <param name="rebootafter" value="1" />
</plugin>
</settings>

Code:

from xml.dom import minidom
yXML = minidom.parse('data/config.xml')

for plugin in yXML.getElementsByTagName('plugin'):
    print plugin.getAttribute('id')+"- "+plugin.getAttribute('name')

selection = raw_input("Enter your choice: ")
selection = plugin.getAttribute('id')
if selection:
    import os
    exe = plugin.getAttribute('execute')
    os.system('python '+exe)

When I type 1 or 2 as Input, It opens number 3. Could you help?

Output:

ubuntu:~/Desktop$ python test.py
1- Send Mail
2- Open Tar
3- Server Reboot
Enter your choice: 1
python: can't open file 'func/reboot.py': [Errno 2] No such file or directory
ubuntu:~/Desktop$

It’s too easy to solve but I can not think very well.

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:09:29+00:00Added an answer on May 26, 2026 at 11:09 am

    When the for loop that prints the values is over, plugin equals the third object (whose id is 3). So every use of plugin after that point will always refer to the server reboot option. Instead, you need:

    [...]
    selection = raw_input("Enter your choice: ")
    plugin = yXML.getElementsByTagName('plugin')[int(selection)]
    if selection:
      [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have a custom XML file format which can contain blocks of code within
I have the following XML code that I'm trying to parse, but I'm sure
My problem is simple but I can't solve it ! I have an XML
I have a little problem that I can't figure out how to solve. I
I have some php files in a server which generate xml code in them.
I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I have some code that uses Open XML to open up a .docx file,
I have a bit of code that basically reads an XML document using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.