From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: How to use xml src block as data input? Date: Sun, 29 Apr 2018 10:30:21 -0700 Message-ID: References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCq9c-0000aK-7A for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 13:30:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCq9a-0004wK-Kx for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 13:30:27 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:39491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fCq9a-0004vf-Cw for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 13:30:26 -0400 Received: by mail-pg0-x231.google.com with SMTP id b9-v6so4817661pgf.6 for ; Sun, 29 Apr 2018 10:30:25 -0700 (PDT) In-reply-to: <87d0yidpoa.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: numbchild@gmail.com Cc: org-mode Here is one approach: #+name: xml-data #+BEGIN_EXAMPLE Tove Jani Reminder Don't forget me this weekend! #+END_EXAMPLE #+BEGIN_SRC python :var data=xml-data import xml.etree.ElementTree as ET root = ET.fromstring(data) for child in root: print(child.tag, child.attrib) #+END_SRC #+RESULTS: : to {} : from {} : heading {} : body {} #+BEGIN_SRC emacs-lisp :var data=xml-data (with-temp-buffer (insert data) (libxml-parse-xml-region (point-min) (point-max))) #+END_SRC #+RESULTS: | note | nil | (to nil Tove) | (from nil Jani) | (heading nil Reminder) | (body nil Don't forget me this weekend!) | stardiviner writes: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > > Is there somebody have any idea or hints about this question? > > - -- > [ stardiviner ] don't need to convince with trends. > Blog: https://stardiviner.github.io/ > IRC(freenode): stardiviner > GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 > > -----BEGIN PGP SIGNATURE----- > > iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrl3cUACgkQG13xyVro > msPaMAgAm6tqsqydqzQjK0a8564JUX+GpP/YBa+WajidIoW7FFY0xpcyV6J1kbYg > 3nTwmVykJ6DiFVQZS2h2dazdn/pQHkkTgMKSvI6XHUVIFCNxC+12bJgQQ5dQJZuX > gbctNMQoXFL6YDBbil2ky2NM8mZRiQcBMyo5B2okiVGxd8CV7Ko+Bu5J1mq/3HJb > assmXwXQiUOkmHBK29soT7Fa9iVWtk96PSmL/tzEdO9G2zyE5aDtnPT+iFSlUgqi > vVCvLhYPsjyYZ7r19swTyZbeVH0av7GzqdJB18jpe1XvwBKJzdicAMP0ilJ1D4c2 > jJFyOETQDkG+T1XQYqU7u94e79tJHg== > =P1VJ > -----END PGP SIGNATURE----- -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu