0

I made an application that depends on the data taken form an XML file, and if the user want to update something in that application he have to change the data contained in that xml file, but for sure i can't ask the user to open the XML file and change it himself, so is there is a way or an interface that can be used to edit this XML file or something that helps me build that interface?

HINT: the changes that have to be made to the xml file to update the application is a slight changes like adding or removing a node.

Refaat
  • 107
  • 1
  • 4
  • 13

1 Answers1

0

Yes, its possible to read and write XML files using XML parsers. Every programming language has bunch of libraries to deal with the same. For python, we can use xml or lxml

with open("xmlfile.xml", "rw") as f:
    doc = ET.parse(f)
    print "Original XML Contents :"
    print ET.tostring(doc)
    root = doc.getroot()
    library = root.find("library")
    library.text = "lxml"
    print "Updated XML Contents :"
    updated = ET.tostring(doc)
    print updated

This produces, output like:

Original XML Contents :
<root>
    <library>xml</library>
    <language>python</language>
</root>
Updated XML Contents :
<root>
    <library>lxml</library>
    <language>python</language>
</root>

This updated XML can easily be written to a file. For more info checkout: lxml

Thanks!

Rahul Tanwani
  • 441
  • 3
  • 10
  • thanks for your interest, but i'm not plan to work by any programming language or by any type of code, because this interface will be dealt with by a foreign customer that can't understand what the meaning of programming, i just want to access xml file by adding or deleting nodes via an interface that it's goal is to make that. – Refaat Sep 01 '13 at 13:46
  • 1
    That's what the purpose is. You can build a nice UI, which will allow your customer to update the xml, by pressing some buttons, and entering some values in the text boxes, this will intern change the xml file in the background. – Rahul Tanwani Sep 01 '13 at 14:28
  • yea but i don't want to build a whole interface, so i'm asking for a ready exist one – Refaat Sep 02 '13 at 13:16