From fredrik at pythonware.com Thu Mar 2 11:06:51 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Mar 2006 11:06:51 +0100 Subject: [XML-SIG] ET/cET sources now available via subversion Message-ID: thanks to the nice folks over at python-hosting.com, a number of ET/cET releases are now available from svn.effbot.python-hosting.com. latest public release (currently elementtree-1.2.6-20050316, celementtree-1.0.5-20051216): svn co http://svn.effbot.python-hosting.com/elementtree svn co http://svn.effbot.python-hosting.com/celementtree tagged releases: svn co http://svn.effbot.python-hosting.com/tags/elementtree-1.2.6-20050316 svn co http://svn.effbot.python-hosting.com/tags/elementtree-1.2.5-20050302 svn co http://svn.effbot.python-hosting.com/tags/elementtree-1.2.4-20041228 svn co http://svn.effbot.python-hosting.com/tags/celementtree-1.0.5-20051216 svn co http://svn.effbot.python-hosting.com/tags/celementtree-1.0.4-20051213 svn co http://svn.effbot.python-hosting.com/tags/celementtree-1.0.2-20050302 source browser: http://effbot.python-hosting.com/browser/ (note that this isn't the main development repository; all releases on python-hosting.com are so-called "vendor drops".) enjoy /F From noreply at sourceforge.net Sat Mar 4 05:16:06 2006 From: noreply at sourceforge.net (SourceForge.net) Date: Fri, 03 Mar 2006 20:16:06 -0800 Subject: [XML-SIG] [ pyxml-Patches-1442890 ] TreeWalker iterates past root node Message-ID: Patches item #1442890, was opened at 2006-03-04 04:16 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1442890&group_id=6473 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: J Robert Ray (jrray) Assigned to: Nobody/Anonymous (nobody) Summary: TreeWalker iterates past root node Initial Comment: TreeWalker fails to stop iterating when it reaches the root node (of a subtree), and will continue returning nodes until it hits the end of the document. The broken behavior is due to a couple typos in the code, this patch fixes the typos and includes a test case that exercises the bug. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1442890&group_id=6473 From noreply at sourceforge.net Tue Mar 7 01:43:04 2006 From: noreply at sourceforge.net (SourceForge.net) Date: Mon, 06 Mar 2006 16:43:04 -0800 Subject: [XML-SIG] [ pyxml-Patches-1444526 ] c14n.py: http://www.w3.org/TR/xml-exc-c14n/ fix Message-ID: Patches item #1444526, was opened at 2006-03-07 00:43 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1444526&group_id=6473 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Joshua Boverhof (boverhof) Assigned to: Nobody/Anonymous (nobody) Summary: c14n.py: http://www.w3.org/TR/xml-exc-c14n/ fix Initial Comment: Included in this patch is: [ 829905 ] c14n.py fix for bug #825115 Fixed a few problems with http://www.w3.org/TR/xml-exc-c14n/. -- include dependent namespace declarations declared in ancestor nodes (checking attributes and tags), -- handle InclusiveNamespaces PrefixList parameter ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=306473&aid=1444526&group_id=6473 From szybalski at gmail.com Tue Mar 7 18:23:55 2006 From: szybalski at gmail.com (Lukasz Szybalski) Date: Tue, 07 Mar 2006 11:23:55 -0600 Subject: [XML-SIG] python xml Message-ID: <440DC1AB.4080905@gmail.com> Hello, I am new to xml in python, but not new to python. After searching for quite a bit, I can't seem to find the answer to this easy coding problem. I have a xml file that i need to find an element with id = 2 extract second child from it, and pass it on to the rest of my program. How can i do it in "<10" lines of code in python? --sample-File------default.xml-- out Hello, I'm out of office...etc.. in Hello, I'm in the office...etc.. ---python -- # I found most of the info/how to on minidom, so I assume minidom is the best choice here from xml.dom import minidom, Node #parse a file, doc=minidom.parse('default.xml') # find attribute .....and here I find myself reading tons of how to, but can't seem to find what i'm looking for. . #how can i do something like: (please correct me here) for x in doc.nodeList: if x.attribute.get('id')==2: pass_it_on = ???? #How do I get to and extract it as string? ---------EOF------ Thanks for the help Lucas From csad7 at t-online.de Wed Mar 8 14:03:34 2006 From: csad7 at t-online.de (Christof) Date: Wed, 08 Mar 2006 14:03:34 +0100 Subject: [XML-SIG] python xml (Lukasz Szybalski) In-Reply-To: References: Message-ID: <440ED626.2020809@t-online.de> > I am new to xml in python, but not new to python. After searching for > quite a bit, I can't seem to find the answer to this easy coding problem. > I have a xml file that i need to find an element with id = 2 extract > second child from it, and pass it on to the rest of my program. > > How can i do it in "<10" lines of code in python? > > --sample-File------default.xml-- > > > out > Hello, > I'm out of office...etc.. > > > > in > Hello, > I'm in the office...etc.. > > your XML is missing a root element (2 response elements) and is therefor not wellformed, see below > ---python -- > # I found most of the info/how to on minidom, so I assume minidom is the > best choice here > > from xml.dom import minidom, Node > #parse a file, > doc=minidom.parse('default.xml') > # find attribute > > .....and here I find myself reading tons of how to, but can't seem to > find what i'm looking for. . > > #how can i do something like: (please correct me here) > for x in doc.nodeList: > if x.attribute.get('id')==2: > pass_it_on = ???? #How do I get to and extract it as > string? > xml = """ out Hello, I'm out of office...etc.. in Hello, I'm in the office...etc.. """ from xml.dom import minidom, Node def elementWithAttVal(e, a, v): children = [x for x in e.childNodes if x.nodeType == e.ELEMENT_NODE] for x in children: if x.getAttribute(a) == v: return x if x.childNodes: t = elementWithAttVal(x, a, v) if t: return t doc = minidom.parseString(xml) id2element = elementWithAttVal(doc, "id", "2") # 1st child element, easy breakable... textelement = id2element.getElementsByTagName('text')[0] # text Node of the element textelement_textnode = textelement.firstChild # value of text node print textelement_textnode.nodeValue Maybe not the easiest implementation but nevertheless it works and shows DOMs rather complicated working... I guess minidom is convinient as included in stdlib but not convinient in usage ;) Easiest IMHO would be using XPath. 4suite or any other implementation would be fine, shown is 4suits xpath command line helper: > 4xpath default.xml "//*[@id=2]/*[2]/text()" Result (XPath node-set): ======================== chris From David.Webster at i-o.com Wed Mar 8 22:37:43 2006 From: David.Webster at i-o.com (David Webster) Date: Wed, 8 Mar 2006 15:37:43 -0600 Subject: [XML-SIG] python xml (Lukasz Szybalski) Message-ID: <78B44E1448B1EC49888FF6DEDD72FF841A601F@STAFEXVS04.ioinc.ioroot.tld> Look at BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/ The BeautifulSOAP class may do what you need. > Date: Tue, 07 Mar 2006 11:23:55 -0600 > From: Lukasz Szybalski > Subject: [XML-SIG] python xml > To: xml-sig at python.org > Message-ID: <440DC1AB.4080905 at gmail.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hello, > I am new to xml in python, but not new to python. After searching for > quite a bit, I can't seem to find the answer to this easy > coding problem. > I have a xml file that i need to find an element with id = 2 extract > second child from it, and pass it on to the rest of my program. > > How can i do it in "<10" lines of code in python? > > --sample-File------default.xml-- > > > out > Hello, > I'm out of office...etc.. > > > > in > Hello, > I'm in the office...etc.. > > > > > ---python -- > # I found most of the info/how to on minidom, so I assume > minidom is the > best choice here > > from xml.dom import minidom, Node > #parse a file, > doc=minidom.parse('default.xml') > # find attribute > > .....and here I find myself reading tons of how to, but can't seem to > find what i'm looking for. . > > #how can i do something like: (please correct me here) > for x in doc.nodeList: > if x.attribute.get('id')==2: > pass_it_on = ???? #How do I get to and > extract it as > string? > > ---------EOF------ > Thanks for the help > Lucas > From mgarcia at accopensys.com Fri Mar 31 21:46:57 2006 From: mgarcia at accopensys.com (Marc Garcia) Date: Fri, 31 Mar 2006 21:46:57 +0200 Subject: [XML-SIG] XML from scratch and transformation with XSLT Message-ID: <442D8731.5010808@gmail.com> I want to make a simple program in python that get data from a database (or other source), create a new xml document with it and then parse it with an existing xslt sheet. I'm testing many libraries, such as libxml2/libxslt, lxml, 4suite, and in different ways, dom and sax methods... Do somebody know what is the simplest way to achieve it? I'm having some problems with all of it (encoding problems, installation bugs, more than one library required...) and I need some expert tips to know what way I have to work on. Thanks in advance, Marc