From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: How to use xml src block as data input? Date: Fri, 30 Mar 2018 13:59:09 +0800 Message-ID: <87efk214uq.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1nkM-0001rH-8X for emacs-orgmode@gnu.org; Fri, 30 Mar 2018 02:42:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1nkJ-0003Kx-1Y for emacs-orgmode@gnu.org; Fri, 30 Mar 2018 02:42:46 -0400 Received: from [183.249.136.119] (port=3114 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1nkI-0003H1-Jj for emacs-orgmode@gnu.org; Fri, 30 Mar 2018 02:42:42 -0400 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: org-mode -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 I have a xml src block like this: #+NAME: xml-sample #+begin_src xml Example Feed 2003-12-13T18:30:02Z John Doe urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 Atom-Powered Robots Run Amok urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a 2003-12-13T18:30:02Z Some text. #+end_src How can I use this xml data as input in another src block? I tried like this: #+begin_src emacs-lisp :var sample=xml-sample (elfeed-xml-parse-region sample) #+end_src But it reports no org-babel-execute for xml! -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlq90i4ACgkQG13xyVro msNFbgf+KgmjYmlNryZ9m63UBOmpCUhQ0zkwGQWzwYs7imvfhmPGBjYR/kIVyIp6 PDi7vlT6KfzewNxOSXAH8gM2Vgy61rbzEdZNqNAEpZC+Xeigh0gh7Zllajj7pSBA 6MiyzLO5fAsh0QsYHW3ZvCME1uFHe1g7zI9ojhdHgOoPW/U2jVw5VkY+PbnEA/jd U5CsxoN562HWpvHTwHQX7cmRbm8xCx3zcyyKZyuxTNoCE2Js/ylyJIfZTnAJDd4o IQj1pR0jIizvB4BR5E5DHXXLTAfYXfZJQYqFyY8eDgAvbZ/V9TURqGGhoXLCiH6T DmnnObUBPJwBC2LK+VcvxFo4BE1oDw== =F3Fs -----END PGP SIGNATURE----- From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: How to use xml src block as data input? Date: Sun, 29 Apr 2018 22:59:17 +0800 Message-ID: <87d0yidpoa.fsf@gmail.com> References: <87efk214uq.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCnnZ-0002ku-HX for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 10:59:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCnnW-0007oc-Gz for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 10:59:33 -0400 Received: from [183.249.129.92] (port=3448 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCnnW-0007mO-0q for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 10:59:30 -0400 In-reply-to: <87efk214uq.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: org-mode =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Is there somebody have any idea or hints about this question? =2D --=20 [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrl3cUACgkQG13xyVro msPaMAgAm6tqsqydqzQjK0a8564JUX+GpP/YBa+WajidIoW7FFY0xpcyV6J1kbYg 3nTwmVykJ6DiFVQZS2h2dazdn/pQHkkTgMKSvI6XHUVIFCNxC+12bJgQQ5dQJZuX gbctNMQoXFL6YDBbil2ky2NM8mZRiQcBMyo5B2okiVGxd8CV7Ko+Bu5J1mq/3HJb assmXwXQiUOkmHBK29soT7Fa9iVWtk96PSmL/tzEdO9G2zyE5aDtnPT+iFSlUgqi vVCvLhYPsjyYZ7r19swTyZbeVH0av7GzqdJB18jpe1XvwBKJzdicAMP0ilJ1D4c2 jJFyOETQDkG+T1XQYqU7u94e79tJHg=3D=3D =3DP1VJ =2D----END PGP SIGNATURE----- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: How to use xml src block as data input? Date: Sun, 29 Apr 2018 17:14:57 +0200 Message-ID: <87fu3e3uz2.fsf@gnu.org> References: <87efk214uq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCo2a-0007sY-K3 for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 11:15:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCo2Z-0003l8-QF for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 11:15:04 -0400 In-Reply-To: <87efk214uq.fsf@gmail.com> (stardiviner's message of "Fri, 30 Mar 2018 13:59:09 +0800") 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: stardiviner Cc: org-mode Hi, stardiviner writes: > How can I use this xml data as input in another src block? You would need to enclose the xml code within #+begin_example instead of #+begin_src. Also, elfeed-xml-parse-region will not work on a string, it expects other arguments, so you might need to write your own parsing function, maybe based on libxml-parse-xml-region if your version of Emacs has libxml support. HTH, -- Bastien 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: How to use xml src block as data input? Date: Mon, 30 Apr 2018 11:42:52 +0800 Message-ID: <87a7tl8imb.fsf@gmail.com> References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCziX-0005Pp-Jf for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 23:43:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fCziU-0001hx-GR for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 23:43:09 -0400 Received: from [183.249.129.92] (port=4296 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fCziU-0001eZ-0V for emacs-orgmode@gnu.org; Sun, 29 Apr 2018 23:43:06 -0400 In-reply-to: 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: John Kitchin Cc: org-mode -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Thanks, I forgot to mention I know example block can be used as input. But this will lose the syntax highlighting. If there is no better solution. I guess it is the best for now. - -- [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrmkL0ACgkQG13xyVro msOU6gf/UNiTzSt8Cizpk1FLBjJJiqOMfWdvp+jJVoNOCJzaxkHFAiwjbEyIf9B5 k27Zw3Gh60rT0iz/RYscptv2keTieUwU0rf23oyouFESgIBaICfRRYzZZ0ZUWTHO 9VGILsaQfOZfO4lenZGMnWGt583DCV1CxEqcODQj2Z7DFb8EfxvRiGup9qPjMSVq 65gu7/Vk2Y2d+cvUZU7t592b7D/5na5Dxy0jkuAEttXjoJrk4OHoxcmYMjbnoimq DSUyu467YqtKKyyOgC8hEnatarkItDp6O5v/P8Ki/iVV5zSTiqkhriQYI9k/sPTV xmI9WZEFOB5A8auvw9csQTUUny2Mjw== =qQac -----END PGP SIGNATURE----- From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?Simonyi_Andr=C3=A1s?= Subject: Re: How to use xml src block as data input? Date: Mon, 30 Apr 2018 09:47:32 +0000 Message-ID: References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> <87a7tl8imb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fD5PO-0004XU-Lm for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 05:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fD5PN-0000IQ-P8 for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 05:47:46 -0400 Received: from mail-vk0-x229.google.com ([2607:f8b0:400c:c05::229]:44768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fD5PN-0000Hw-JW for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 05:47:45 -0400 Received: by mail-vk0-x229.google.com with SMTP id x66-v6so175820vka.11 for ; Mon, 30 Apr 2018 02:47:43 -0700 (PDT) In-Reply-To: <87a7tl8imb.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: emacs-orgmode list , John Kitchin Hello, if having the data in a source block is a must, then, as a last resort, you might try to pull the block's content from the buffer's parse tree: #+begin_src emacs-lisp :var src-block-name="xml-sample" (let ((xml-str (org-element-map (org-element-parse-buffer) 'src-block (lambda (x) (and (string= src-block-name (org-element-property :name x)) (org-element-property :value x))) nil t))) (with-temp-buffer (insert xml-str) (libxml-parse-xml-region (point-min) (point-max)))) #+end_src On Mon, 30 Apr 2018 at 05:43, stardiviner wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > Thanks, I forgot to mention I know example block can be used as input. > But this will lose the syntax highlighting. If there is no better solution. > I guess it is the best for now. > - -- > [ stardiviner ] don't need to convince with trends. > Blog: https://stardiviner.github.io/ > IRC(freenode): stardiviner > GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 > -----BEGIN PGP SIGNATURE----- > iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrmkL0ACgkQG13xyVro > msOU6gf/UNiTzSt8Cizpk1FLBjJJiqOMfWdvp+jJVoNOCJzaxkHFAiwjbEyIf9B5 > k27Zw3Gh60rT0iz/RYscptv2keTieUwU0rf23oyouFESgIBaICfRRYzZZ0ZUWTHO > 9VGILsaQfOZfO4lenZGMnWGt583DCV1CxEqcODQj2Z7DFb8EfxvRiGup9qPjMSVq > 65gu7/Vk2Y2d+cvUZU7t592b7D/5na5Dxy0jkuAEttXjoJrk4OHoxcmYMjbnoimq > DSUyu467YqtKKyyOgC8hEnatarkItDp6O5v/P8Ki/iVV5zSTiqkhriQYI9k/sPTV > xmI9WZEFOB5A8auvw9csQTUUny2Mjw== > =qQac > -----END PGP SIGNATURE----- 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: Mon, 30 Apr 2018 06:34:27 -0700 Message-ID: References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> <87a7tl8imb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fD8ws-0005VW-T0 for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 09:34:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fD8wr-0006Q8-GF for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 09:34:34 -0400 Received: from mail-pf0-x22b.google.com ([2607:f8b0:400e:c00::22b]:42611) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fD8wr-0006Pk-9H for emacs-orgmode@gnu.org; Mon, 30 Apr 2018 09:34:33 -0400 Received: by mail-pf0-x22b.google.com with SMTP id a11so6747152pfn.9 for ; Mon, 30 Apr 2018 06:34:33 -0700 (PDT) In-reply-to: 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: Simonyi =?utf-8?Q?Andr=C3=A1s?= Cc: emacs-orgmode list Here is a minor variation on this idea: #+name: xml-example #+BEGIN_SRC xml Tove Jani Reminder Don't forget me this weekend! #+END_SRC #+BEGIN_SRC emacs-lisp :var name="xml-example" (save-excursion (org-babel-goto-named-src-block name) (let ((data (org-element-property :value (org-element-context)))) (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!) | Simonyi AndrĂ¡s writes: > Hello, > > if having the data in a source block is a must, then, as a last resort, > you might try to pull the block's content from the buffer's parse tree: > > #+begin_src emacs-lisp :var src-block-name="xml-sample" > (let ((xml-str > (org-element-map (org-element-parse-buffer) 'src-block > (lambda (x) > (and (string= src-block-name (org-element-property :name x)) > (org-element-property :value x))) > nil t))) > (with-temp-buffer (insert xml-str) (libxml-parse-xml-region (point-min) > (point-max)))) > #+end_src > On Mon, 30 Apr 2018 at 05:43, stardiviner wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA256 > > >> Thanks, I forgot to mention I know example block can be used as input. >> But this will lose the syntax highlighting. If there is no better > solution. >> I guess it is the best for now. > >> - -- >> [ stardiviner ] don't need to convince with trends. >> Blog: https://stardiviner.github.io/ >> IRC(freenode): stardiviner >> GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 >> -----BEGIN PGP SIGNATURE----- > >> iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrmkL0ACgkQG13xyVro >> msOU6gf/UNiTzSt8Cizpk1FLBjJJiqOMfWdvp+jJVoNOCJzaxkHFAiwjbEyIf9B5 >> k27Zw3Gh60rT0iz/RYscptv2keTieUwU0rf23oyouFESgIBaICfRRYzZZ0ZUWTHO >> 9VGILsaQfOZfO4lenZGMnWGt583DCV1CxEqcODQj2Z7DFb8EfxvRiGup9qPjMSVq >> 65gu7/Vk2Y2d+cvUZU7t592b7D/5na5Dxy0jkuAEttXjoJrk4OHoxcmYMjbnoimq >> DSUyu467YqtKKyyOgC8hEnatarkItDp6O5v/P8Ki/iVV5zSTiqkhriQYI9k/sPTV >> xmI9WZEFOB5A8auvw9csQTUUny2Mjw== >> =qQac >> -----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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [SOLVED] How to use xml src block as data input? Date: Tue, 01 May 2018 11:36:21 +0800 Message-ID: <87muxk3v4a.fsf@gmail.com> References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> <87a7tl8imb.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDMeF-0008S9-Pg for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:12:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDMeC-0006lL-Gg for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:12:15 -0400 Received: from [183.246.147.11] (port=2296 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDMeC-0006eC-41 for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:12:12 -0400 In-reply-to: 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: John Kitchin Cc: emacs-orgmode list , Simonyi =?utf-8?Q?Andr=C3=A1s?= =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Thanks, John and Simonyi. This is a solution on Elisp. Not general way. But as a intermedia step, really workable. I chose this method. BTW, is it possible to archived with noweb reference <> ? Like #+begin_src python :var data=3D<> ... #+end_src =2D --=20 [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrn4LYACgkQG13xyVro msP8ywf/VaaQkpFcV16/2NDRODkC+iNN6TCp1MRJjYL9qkppa/A8vRGPZSxIG5Sd d2TEGx+mqRS0EANM/mhJwAIlM5U9SpycBfzasvU7R+Cn9CiehZCnJKA0dBaZiu+q vPBifqEqOzY873XsaRS2Xty6W4NSrh8aL6hEWxiDJSafjaCxI2FvApg2JnPi6HoC /sy9eSuIYvG8vCRow9y8E/GFcWE5EXoB/d/mdcEmGz80sB39Tjp4PGvLMyglROMa sR+8QkUTQAtDP4uEAF7biHAGE2PcELpZVLjzWm0GfZkCdJF9tH8KrEXaorB+hyHn MWxzlZ/gSNcsROF7DHVaZgCMMiiXuw=3D=3D =3DfImh =2D----END PGP SIGNATURE----- From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: [SOLVED] How to use xml src block as data input? Date: Mon, 30 Apr 2018 21:14:44 -0700 Message-ID: References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> <87a7tl8imb.fsf@gmail.com> <87muxk3v4a.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d8e040056b1d352c" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDMgi-0000lQ-DC for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:14:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDMgg-0007jO-TZ for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:14:48 -0400 Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:41021) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fDMgg-0007j5-FV for emacs-orgmode@gnu.org; Tue, 01 May 2018 00:14:46 -0400 Received: by mail-wr0-x232.google.com with SMTP id g21-v6so9838513wrb.8 for ; Mon, 30 Apr 2018 21:14:46 -0700 (PDT) In-Reply-To: <87muxk3v4a.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: stardiviner Cc: emacs-orgmode list , =?UTF-8?Q?Simonyi_Andr=C3=A1s?= --000000000000d8e040056b1d352c Content-Type: text/plain; charset="UTF-8" all things in emacs are elisp... You can use this function: #+BEGIN_SRC emacs-lisp (defun get-xml (name) (save-excursion (org-babel-goto-named-src-block name) (org-element-property :value (org-element-context)))) #+END_SRC #+RESULTS: : get-xml like this in a python (or other general lang) block to get the xml as a string that you parse in the language: #+BEGIN_SRC python :var data=(get-xml "xml-example") 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 {} I don't know about noweb. John ----------------------------------- 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 On Mon, Apr 30, 2018 at 8:36 PM, stardiviner wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Thanks, John and Simonyi. This is a solution on Elisp. Not general way. > But as a intermedia step, really workable. I chose this method. > > BTW, is it possible to archived with noweb reference <> ? > Like > > #+begin_src python :var data=<> > ... > #+end_src > > - -- > [ stardiviner ] don't need to convince with trends. > Blog: https://stardiviner.github.io/ > IRC(freenode): stardiviner > GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 > > -----BEGIN PGP SIGNATURE----- > > iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrn4LYACgkQG13xyVro > msP8ywf/VaaQkpFcV16/2NDRODkC+iNN6TCp1MRJjYL9qkppa/A8vRGPZSxIG5Sd > d2TEGx+mqRS0EANM/mhJwAIlM5U9SpycBfzasvU7R+Cn9CiehZCnJKA0dBaZiu+q > vPBifqEqOzY873XsaRS2Xty6W4NSrh8aL6hEWxiDJSafjaCxI2FvApg2JnPi6HoC > /sy9eSuIYvG8vCRow9y8E/GFcWE5EXoB/d/mdcEmGz80sB39Tjp4PGvLMyglROMa > sR+8QkUTQAtDP4uEAF7biHAGE2PcELpZVLjzWm0GfZkCdJF9tH8KrEXaorB+hyHn > MWxzlZ/gSNcsROF7DHVaZgCMMiiXuw== > =fImh > -----END PGP SIGNATURE----- > --000000000000d8e040056b1d352c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
all things in emacs are elisp...

You ca= n use this function:

#+BEGIN_SRC emacs-lisp
(defun get-xml (name)
=C2=A0 (save-excursion
=C2= =A0 =C2=A0 (org-babel-goto-named-src-block name)
=C2=A0 =C2=A0 (o= rg-element-property :value (org-element-context))))
#+END_SRC

#+RESULTS:
: get-xml

like this in a python (or other general lang) block to get the xml as a = string that you parse in the language:

#+BEGIN_SRC= python :var data=3D(get-xml "xml-example")
import xml.= etree.ElementTree as ET
root =3D ET.fromstring(data)
fo= r child in root:
=C2=A0 =C2=A0 print(child.tag, child.attrib)
#+END_SRC

#+RESULTS:
: to {}
: from {}
: heading {}
: body {}

I don't know about noweb.

John
=
-----------------------------------
Professor John Kitchin=C2=A0
= Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon= University
Pittsburgh, PA 15213
412-268-7803

On Mon, Apr 30, 2018 at 8:36 PM, stardiviner= <numbchild@gmail.com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Thanks, John and Simonyi. This is a solution on Elisp. Not general w= ay.
But as a intermedia step, really workable. I chose this method.

BTW, is it possible to archived with noweb reference <<xml-data>&g= t; ?
Like

#+begin_src python :var data=3D<<xml-data>>
...
#+end_src

- --
[ stardiviner ] don't need to convince with trends.
=C2=A0 =C2=A0 =C2=A0 =C2=A0Blog: https://stardiviner.github.io/ =C2=A0 =C2=A0 =C2=A0 =C2=A0IRC(freenode): stardiviner
=C2=A0 =C2=A0 =C2=A0 =C2=A0GPG: F09F650D7D674819892591401B5DF1C95AE89A= C3

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrn4LYACgkQG13xyVro
msP8ywf/VaaQkpFcV16/2NDRODkC+iNN6TCp1MRJjYL9qkppa/A8vRGPZSxIG5Sd<= br> d2TEGx+mqRS0EANM/mhJwAIlM5U9SpycBfzasvU7R+Cn9CiehZCnJKA0dBaZiu+q<= br> vPBifqEqOzY873XsaRS2Xty6W4NSrh8aL6hEWxiDJSafjaCxI2FvApg2JnPi6HoC<= br> /sy9eSuIYvG8vCRow9y8E/GFcWE5EXoB/d/mdcEmGz80sB39Tjp4PGvLMyglROMa<= br> sR+8QkUTQAtDP4uEAF7biHAGE2PcELpZVLjzWm0GfZkCdJF9tH8KrEXaorB+= hyHn
MWxzlZ/gSNcsROF7DHVaZgCMMiiXuw=3D=3D
=3DfImh
-----END PGP SIGNATURE-----

--000000000000d8e040056b1d352c-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [SOLVED] How to use xml src block as data input? Date: Tue, 01 May 2018 21:10:16 +0800 Message-ID: <87vac7y11j.fsf@gmail.com> References: <87efk214uq.fsf@gmail.com> <87d0yidpoa.fsf@gmail.com> <87a7tl8imb.fsf@gmail.com> <87muxk3v4a.fsf@gmail.com> Reply-To: numbchild@gmail.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDV3B-0002KR-Gf for emacs-orgmode@gnu.org; Tue, 01 May 2018 09:10:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDV38-0004Td-BP for emacs-orgmode@gnu.org; Tue, 01 May 2018 09:10:33 -0400 Received: from [183.246.147.11] (port=2314 helo=dark.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDV37-0004On-UC for emacs-orgmode@gnu.org; Tue, 01 May 2018 09:10:30 -0400 In-reply-to: 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: John Kitchin Cc: emacs-orgmode list , Simonyi =?utf-8?Q?Andr=C3=A1s?= =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 This is great. Thanks John. =2D --=20 [ stardiviner ] don't need to convince with trends. Blog: https://stardiviner.github.io/ IRC(freenode): stardiviner GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 =20=20=20=20=20=20 =2D----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlroZzkACgkQG13xyVro msO8kQf+OhzChdi9GRrjKEJOQNod2Gg9g86eGBu5w97ZOHgj/MkOzu2jd3AMxKDN mt6LKXmcJCDEzKIO36xiiypdckwfU98zAZGrpLFbUlYZ3wdLT/HY1XWXkOHGiQvk h6rxi7jWdkKw4/tSMZ/Mh70bJ803Y2jZ5JnKx4hwVlgBfoettgWfRf6h91Zg/VcU QDrIMG5aYcgoMA0GwWtOWeYuYIkq18/Elg6gQhSg+vIe0s0U/4qoArlIFL0AoZcF qwBZ1hBukWOf1gHvvI8rjbqQ4BOFFjDSbPS6/C+NMZL7oDkbpErH5JAaZTsYYH5e QBLsOjao+bG1d+7TtZzD92kAsWN5Kg=3D=3D =3D/XVs =2D----END PGP SIGNATURE-----