emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to use xml src block as data input?


From: John Kitchin
Subject: Re: [O] How to use xml src block as data input?
Date: Sun, 29 Apr 2018 10:30:21 -0700
User-agent: mu4e 1.0; emacs 25.3.1

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 via email to

[Prev in Thread] Current Thread [Next in Thread]