According to the documentation for cxml:make-string-sink
, the string sinks return their strings as a result of a call to sax:end-document
, so one thing you could do would be:
(let ((sink (cxml:make-string-sink)))
(cxml-stp:serialize
(let ((last-step
(car
(cxml-stp:filter-children #'(lambda(node)
(and (typep node 'stp:element)
(string= (stp:local-name node)
"WANNAPRINT")))
(cxml-stp:first-child
(cxml:parse
"<EXAMPLE> <WANNAPRINT> AWESOME </WANNAPRINT> <DONTWANNAPRINT> BAD </DONTWANNAPRINT> </EXAMPLE>"
(stp:make-builder)))))))
(FORMAT t "last-step:~a~%" last-step)
last-step)
sink)
(sax:end-document sink))
This seems a little icky, but there doesn't seem to be a mechanism exported to get at the ystream inside the sink.
Another way to do it would be to put your element
(that is, last-step
) in a document
. I thought it would be as simple as (stp:make-document last-step)
but it complains that the element already has a parent and I don't remember how to get around that right now. In any case, you might not want a document because its serialization includes the prelude (<?xml
...?>
).