unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* sxml: avoiding intermixed text?
@ 2011-01-10 11:21 Aleix Conchillo Flaqué
  2011-01-13 10:47 ` [SOLVED] " Aleix Conchillo Flaqué
  0 siblings, 1 reply; 4+ messages in thread
From: Aleix Conchillo Flaqué @ 2011-01-10 11:21 UTC (permalink / raw)
  To: guile-user

Hi!

is there an easy way to avoid intermixed text from xml? For example, 
given this XML:

<?xml version="1.0"?>

<test>
   <check><value>empty</value></check>
   <check>
     <value>hi!
     this is just a test!
     </value>
   </check>
</test>

the following code:

-------------
(use-modules (sxml simple))
(use-modules (sxml xpath))

(let ((sxml (with-input-from-file "test.xml" xml->sxml)))
   (map
    (lambda (c) (pk (cdr c)))
    ((sxpath '(// check)) sxml)))
-------------

Returns:

-------------
;;; (((value "empty")))

;;; (("
     " (value "hi!
     this is just a test!
     ") "
   "))
-------------

I'd like to get rid of the (car) of the second print. Or saying it in 
another way, I want to get rid of all text that is not a leaf.

I'm using xpath to find my elements, which is what I found easiest from 
all the sxml stuff. May be I should do it some other way.

Any help would be welcome!

Cheers,

Aleix




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-13 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-10 11:21 sxml: avoiding intermixed text? Aleix Conchillo Flaqué
2011-01-13 10:47 ` [SOLVED] " Aleix Conchillo Flaqué
2011-01-13 10:53   ` Thien-Thi Nguyen
2011-01-13 11:20     ` Aleix Conchillo Flaqué

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).