Re: [Tutor] XML Programs

2018-04-21 Thread Albert-Jan Roskam
On Apr 21, 2018 09:06, Peter Otten <__pete...@web.de> wrote: > > Glen wrote: > > > Thank you for your comprehensive reply. It was very helpful! > > Just to clarify one point, is it not possible to search for a node > > directly in the element / elementTree or do you first need to pull the > > data

Re: [Tutor] XML Programs

2018-04-21 Thread Peter Otten
Glen wrote: > Thank you for your comprehensive reply. It was very helpful! > Just to clarify one point, is it not possible to search for a node > directly in the element / elementTree or do you first need to pull the > data into a class/dict? You certainly have other options >>> catalog.xpath("/

Re: [Tutor] XML Programs

2018-04-19 Thread Peter Otten
Glen wrote: > Hey guys, > > I have the following code: > > https://repl.it/@glendog/HurtfulPunctualInterface from lxml import etree catalog = etree.parse("example.xml") def getbooks(xmldata): books = xmldata.xpath("//catalog")[0] for item in books: print(item.findtext("title")

Re: [Tutor] XML Programs

2018-04-19 Thread Glen
Hey guys, I have the following code: https://repl.it/@glendog/HurtfulPunctualInterface Using the function I have define I can print to screen a list of books. However, how can I search for records within the xml using an ID or the title of the book etc? I've tried reading the tutorial but the pe

Re: [Tutor] XML Programs

2018-04-18 Thread Glen
Hello Stefan, Thank you for this. That's actually quite helpful! Regards, On 17 April 2018 at 19:56, Stefan Behnel wrote: > Glen schrieb am 16.04.2018 um 13:10: > > I'm writing a save-game editor for a game I play (just a project to > learn). > > But I am struggling on how to structure the cod

Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
Glen schrieb am 16.04.2018 um 13:10: > I'm writing a save-game editor for a game I play (just a project to learn). > But I am struggling on how to structure the code, how to store the xml data > in data structure etc, > > Can anyone recommend some source I can review that reads and writes data > f

Re: [Tutor] XML Programs

2018-04-17 Thread Stefan Behnel
leam hall schrieb am 16.04.2018 um 14:54: > On Mon, Apr 16, 2018 at 7:10 AM, Glen wrote: >> I'm writing a save-game editor for a game I play (just a project to learn). >> But I am struggling on how to structure the code, how to store the xml data >> in data structure etc, >> >> Can anyone recommend

Re: [Tutor] XML Programs

2018-04-16 Thread George Fischhof
Hi, Maybe you should give a try to xmltodict package George leam hall ezt írta (időpont: 2018. ápr. 16., H 15:14): > Yeah, understood. > > Okay, knowing that others are smarter about python, and ElementTree, > here's some code I was using to parse XML. Took a while to recover > from. :) > > L

Re: [Tutor] XML Programs

2018-04-16 Thread leam hall
Yeah, understood. Okay, knowing that others are smarter about python, and ElementTree, here's some code I was using to parse XML. Took a while to recover from. :) Leam # import xml.etree.ElementTree as ET import os import argparse import fnmatch def show_info(file, element): action

Re: [Tutor] XML Programs

2018-04-16 Thread Glen
I understand, I'd love to use something else but the save game files are in XML so I have no choice :'( On 16 April 2018 at 13:54, leam hall wrote: > On Mon, Apr 16, 2018 at 7:10 AM, Glen wrote: > > Hey guys, > > > > I'm writing a save-game editor for a game I play (just a project to > learn).

Re: [Tutor] XML Programs

2018-04-16 Thread leam hall
On Mon, Apr 16, 2018 at 7:10 AM, Glen wrote: > Hey guys, > > I'm writing a save-game editor for a game I play (just a project to learn). > But I am struggling on how to structure the code, how to store the xml data > in data structure etc, > > Can anyone recommend some source I can review that rea