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


Reply via email to