emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: numbchild@gmail.com
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: How to use xml src block as data input?
Date: Sun, 29 Apr 2018 10:30:21 -0700	[thread overview]
Message-ID: <m2wowpj4ya.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <87d0yidpoa.fsf@gmail.com>

Here is one approach:

#+name: xml-data
#+BEGIN_EXAMPLE
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
#+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

  reply	other threads:[~2018-04-29 17:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30  5:59 How to use xml src block as data input? stardiviner
2018-04-29 14:59 ` stardiviner
2018-04-29 17:30   ` John Kitchin [this message]
2018-04-30  3:42     ` stardiviner
2018-04-30  9:47       ` Simonyi András
2018-04-30 13:34         ` John Kitchin
2018-05-01  3:36           ` [SOLVED] " stardiviner
2018-05-01  4:14             ` John Kitchin
2018-05-01 13:10               ` stardiviner
2018-04-29 15:14 ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2wowpj4ya.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=numbchild@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).